Aassigning to a reference?
What happens if you assign to a reference?
You change the referrent (the object to which the reference refers).
Remember: the reference IS the referrent, so changing the reference changes the referrent (a reference is an "Lvalue" [something that can appear on the "L"eft-hand-side of an assignment statement] for the referrent).
This insight can be pushed a bit farther by allowing references to be RETURNED. This allows function calls on the left hand side of an assignment statement, which is useful with operator overloading.
Comments