title: Why vector not free objects or what happens anyway?
body: <p>I don't understand what happens here! I define class cVtst, and create vector. I watch when the objects are created and destroyed.</p>
  
  <pre><code>class cVtst { 
  public: 
      int v;
      cVtst(int v) { 
          this-&gt;v = v; 
          printf("Creating cVtst %d\n", v); 
      }
      ~cVtst() { 
          printf("Closing cVtst %d\n", v);
      } 
  };
  
  std::vector&lt;cVtst&gt; vc;
  vc.push_back(34); 
  vc.push_back(2); 
  vc.push_back(-5);
  while (!vc.empty()) vc.pop_back();
  </code></pre>
  
  <p>The result is:</p>
  
  <pre><code>Creating cVtst 34
  Closing cVtst 34
  Creating cVtst 2
  Closing cVtst 34
  Closing cVtst 2
  Creating cVtst -5
  Closing cVtst 34
  Closing cVtst 2
  Closing cVtst -5
  Closing cVtst -5
  Closing cVtst 2
  Closing cVtst 34
  </code></pre>
  
  <p>So ... ?</p>