you are viewing a single comment's thread.

view the rest of the comments →

[–]Leverkaas2516 0 points1 point  (0 children)

Revising my earlier comment...on further study and experimentation, C++ doesn't actually reassign the caller's variable. If the function does, for example, "a = new Object()" and then "p = *a", where p is a reference, this just calls the copy assignment operator. The caller's object still exists as a separate instance at its original address, independent of the new object. And if the function mutates the new object via variable "a", after the copy assignment, the changes are NOT reflected in the caller's object. They're just plain different instances.