About returning references to objects
<p>No, this isn't about the mistake everyone makes of passing locals. I'm just trying to understanding returning a reference to an object you pass in (I'm reading through primer).</p>

<p>So if I have a function like this:</p>

<pre><code>const foo &amp; foo::function2(const foo &amp; val) const
{
    using namespace std;
    return *this;
}
</code></pre>

<p>and then I'm in main doing this:</p>

<pre><code>foo object1;
object1.someproperty = 7;

foo object2 = object1.function2(object1);
object2.someproperty = 5;

cout &lt;&lt; &amp;object1 &lt;&lt; endl;
cout &lt;&lt; &amp;object2 &lt;&lt; endl;
</code></pre>

<p>When I return by reference, shouldn't object2 have the same address (and properties) as object1? Shouldn't changing "someproperty" in one object alter the value in the other? Or, does returning a reference to an object simply copy over the values into the new object? </p>

<p>It seems like the same thing is going on as if I just said that I was going to return a foo object instead of a reference to one.</p>
