References don't have an address. A reference is essentially a label for another variable, and if you take the address of a reference, you'll get the address of the thing it references.
Consider:
void function (bool b, int x, int y)
{
int& ref = b ? x : y;
Here, &ref
will evaluate to either the same thing as &x
or the same thing as &y
, depending on the value of b
.
When you use a reference on the left side of an assignment, it acts the same as if you used the underlying variable. So if you have:
void function (SomeClass y)
{
SomeClass &z (y);
Now, since z
is a reference to y
, y = foo();
and z = foo();
do the same thing.