C++ return a class into a const reference or not?
<p>Assume there is a method which returns a <code>std::set</code>:</p>

<pre><code>std::set&lt;string&gt; MyClass::myMethod() const
{
   std::set&lt;string&gt; result;
   // ... some code to fill result ...
   return result;
}
</code></pre>

<p>In the caller side we can store result of <code>myMethod</code> in two ways:</p>

<pre><code>void MyClass::test()
{
const std::set&lt;string&gt;  s1 = myMethod();  // 1
const std::set&lt;string&gt;&amp; s2 = myMethod();  // 2 (using reference)
// ... some code to use s1 or s2 ...
}
</code></pre>

<p>My questions are:</p>

<ul>
<li>Is there any difference between them?</li>
<li>Which way is better and
efficient?</li>
</ul>
