Reply To: C++ Programming
I said above that a reference is an object but in fact it isn’t. A reference doesn’t have a memory address of its own (though it must be in memory somewhere) , it uses the address of the object it points to so it is in fact an alias. As a result you can’t have a pointer to a reference (there is no address to point to but you can change its value which will change the value of the object it refers to. The syntax for creating a reference is.
int &r = i
r is a reference to i and its type must be the same, ie int in this case. We are using & yet again ! but this time in a declaration so its meaning is different from dereferencing a pointer.