title: C++ best practice: Returning reference vs. object
body: <p>I'm trying to learn C++, and trying to understand returning objects.  I seem to see 2 ways of doing this, and need to understand what is the best practice.</p>
  
  <p>Option 1:</p>
  
  <pre><code>QList&lt;Weight *&gt; ret;
  Weight *weight = new Weight(cname, "Weight");
  ret.append(weight);
  ret.append(c);
  return &amp;ret;
  </code></pre>
  
  <p>Option 2:</p>
  
  <pre><code>QList&lt;Weight *&gt; *ret = new QList();
  Weight *weight = new Weight(cname, "Weight");
  ret-&gt;append(weight);
  ret-&gt;append(c);
  return ret;
  </code></pre>
  
  <p>(of course, I may not understand this yet either).</p>
  
  <p>Which way is considered best-practice, and should be followed?</p>