Proper use of new/delete
<p>As a sequel of my <a href="http://stackoverflow.com/questions/7104889/how-to-properly-define-destructor">previous question</a>, I would like to ask what I am doing wrong in the following code.</p>

<p>The code is, for example</p>

<pre><code>void myclass1::myfun()
{
myclass2* newVar = new myclass2();
/* other code and stuff */
myvector.push_back(newVar); // myvector is a member of myclass1 and is a std::vector&lt;myclass2*&gt;
delete newVar;
}
</code></pre>

<p>but when I run it, myvector returns empty, unless I comment out the <code>delete</code> line.</p>

<p>What am I doing wrong?</p>
