title: C++ Memory allocation question involving vectors
body: <pre><code>vector&lt; int &gt; vect;
  int *int_ptr = new int(10);
  vect.push_back( *int_ptr );
  </code></pre>
  
  <p>I under stand that every "new" needs to be followed by a "delete" at some point but does the clear() method clean this memory?</p>
  
  <p>What about this method of doing the same thing:</p>
  
  <pre><code>vector&lt; int &gt; vect;
  int int_var = 10;
  vect.push_back( int_var );
  </code></pre>
  
  <p>From what I understand, clear() calls the variables destructors, but both vect.push_back() methods in this example push an object on the vector, not a pointer. so does the first example using an int pointer need something other than clear() to clean up memory?</p>