int i; int &j = i; i = 23; j = 0; cout << i << endl; cout << j << endl;
This code prints 0 twice! This is because j
is a reference to
i
. This means j
is an alias of the object that is also
known as i
. When j
appears on the left hand side of
the assignment operator, it specifies the storage of variable i
.