title: Correct way of freeing memory in a vector of pointers? (C++)
body: <p>I have a homework problem, in which I have a <code>class Student</code>, and a vector of pointers to <code>Student</code> objects, which is a member field in the Student class:</p>
  
  <pre><code>vector&lt;Student*&gt; vectorName;
  </code></pre>
  
  <p>In order to do correct(?) memory management, I declared the destructor in the Student class like this </p>
  
  <pre><code>Student::~Student() {
    for(int i=0; i&lt;vectorName.size(); i++){
      delete vectorName.at(i);
    }
  }
  </code></pre>
  
  <p>Does this <strong>really</strong> free the memory correctly from the heap, or is there a better way?</p>