0

Possible Duplicate:
What are the differences between pointer variable and reference variable in C++?

Sometimes I see that kind of declaration:

void f(int& a,...){
 }

What does & mean? Because * is pointer, without * is object, so what is that?

halfer
  • 19,824
  • 17
  • 99
  • 186
Yoda
  • 17,363
  • 67
  • 204
  • 344
  • 2
    It's a reference. http://stackoverflow.com/questions/57483/what-are-the-differences-between-pointer-variable-and-reference-variable-in-c – chris Oct 15 '12 at 22:50
  • 3
    Look at the link. In C, using a pointer was known as passing by reference, but C++ actually has references, which are sometimes a much better fit. No extra syntax, and some semantics differences as well. – chris Oct 15 '12 at 22:54
  • 1
    In "C", "&" is merely the [addressof operator](https://www.techcrashcourse.com/2015/12/pointer-address-of-and-value-of-operator-in-c.html). C++, as Chris said, also has "references": https://www.geeksforgeeks.org/references-in-c/. Your C++ function signature is the latter. – paulsm4 Aug 29 '22 at 20:59

0 Answers0