Empty vector of type <stuff*>
<p>I have a vector populated with objects:</p>

<pre><code>std::vector&lt;Stuff*&gt; stuffVector;
</code></pre>

<p>and am trying to delete all elements of it using a cleanup function</p>

<pre><code>void CleanUp()
{
    for (std::vector&lt;Stuff*&gt;::size_type i = 0 ; i &lt; stuffVector.size() ; i++)
    {
        stuffVector.erase(stuffVector.begin()+i);
    }
    cout &lt;&lt; stuffVector.size() &lt;&lt; endl;
    if (stuffVector.size() == 0) cout &lt;&lt; "Vector Emptied" &lt;&lt; endl;
}
</code></pre>

<p>This always reports back with a size of however many objects are in the vector, and doesn't actually seem to delete anything at all. It's odd as a similar function works elsewhere to delete a specific object from the vector:</p>

<pre><code>void DestroyStuff()
{
    if (stuffVector.size() &gt; 1)
    {
        for (std::vector&lt;Stuff*&gt;::size_type i = 0 ; i &lt; stuffVector.size() ; i++ )
        {
            if(stuffVector[i]-&gt;CanDestroy())
            {
                stuffVector.erase (stuffVector.begin()+i);
            }
        }
    }
}
</code></pre>

<p>The above works fine, but CleanUp() does not. Why might this be happening?</p>
