C++ -- how to design the data structure so that it can avoid the memory leak
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/3447804/vector-of-pointer-to-object-how-to-avoid-memory-leak">vector of pointer to object - how to avoid memory leak?</a>  </p>
</blockquote>



<p>Hello all,</p>

<p>I have the following code,</p>

<pre><code>vector&lt;Student*&gt; vec;
// populate vec with Student pointers
</code></pre>

<p>Then <code>sort(vec.begin(), vec.end(), ...)</code> to sort the Student based on the score.</p>

<p>Here is the question, </p>

<p>Because vector stores the pointers, we have to later remember to remove it manually.
However, we cannot store auto_ptr inside the vector.</p>

<p>Is there a better way for this?
Store a smart pointer inside vector?
How to design this smart pointer?</p>

<p>Thank you</p>
