Are the following two ways of returning an C++ object doing the same?
<p>Suppose a function that create a class and return:</p>

<pre><code>Foo getFoo ()
{
   return Foo ("bar");
}
</code></pre>

<p>And second method:</p>

<pre><code>Foo getFoo ()
{
   Foo foo ("bar");
   return foo;
}
</code></pre>

<p>Now I call it with <code>const Foo &amp; myFoo = getFoo()</code></p>

<p>Is the first method more efficient? They looked same to me, since they both create a temp variable and returns it, am I wrong?</p>
