The &
symbol has multiple meanings in C++. In this context (declaration) &
does not means address of it means reference to. It acts as an alias of the passed in variable such that changing the alias changes the variable itself.
This is completely different (though in some ways similar) to declaring a pointer to a variable that holds its address which is taken using the address of operator (also &
).
So it is all about the context or how the &
is used:
declaration:
int& i = n; // i is an int reference to n (& means reference)
operator:
int* i = &n; // i is an int pointer to n (& means address of)