title: C++ does the iterator need to be deleted?
body: <p>I have a question concerning the release of memory</p>
  
  <p>I'm iterating over a vector in one of my programs. Something like this:</p>
  
  <pre><code>// init vector
  vector&lt;int&gt;* v = new vector&lt;int&gt;();
  // iterate
  for (vector&lt;Column&gt;::iterator it = v-&gt;begin(); it != v-&gt;end(); ++it) {
      // do something with it
  }
  // delete vector
  delete v;
  </code></pre>
  
  <p>However I feel unsure, if I should instead write:</p>
  
  <pre><code>// init vector
  vector&lt;int&gt;* v = new vector&lt;int&gt;();
  // iterate
  vector&lt;Column&gt;::iterator it = v-&gt;begin()
  for (; it != v-&gt;end(); ++it) {
      // do something with it
  }
  delete it;
  // delete vector
  delete v;
  </code></pre>
  
  <p>or is freeing the iterator not necessary, because of freeing the iterator?</p>