Assigning result of function which returns a Foo to a const Foo&
<p>I've got a function which returns an object of type <code>Foo</code>:</p>

<pre><code>Foo getFoo();
</code></pre>

<p>I know the following will compile and will work, but why would I ever do it?</p>

<pre><code>const Foo&amp; myFoo = getFoo();
</code></pre>

<p>To me, the following is much more readable, and doesn't force me to remember that C++ allows me to assign an r-value to a const reference:</p>

<pre><code>const Foo myFoo = getFoo();
</code></pre>

<p>What are the differences between the two? Why would I use the first over the second? Why would I use the second over the first?</p>
