title: stl vector memory management
body: <p>I am using borland 2006 c++, and have following code. I am using vectors, and have trouble understanding why the destructor is not being called.</p>
  
  <p>basically i have a class A</p>
  
  <pre><code>class A
  {
  private:
      TObjectList* list;
      int myid;
  public:
   __fastcall A(int);
   __fastcall ~A();
  };
  
  __fastcall A::A(int num)
  {
      myid = num;
      list = new TObjectList();
  
  }
  
  __fastcall A::~A()
  {
      delete list;
  }
  
  int main(int argc, char* argv[])
  {
      myfunc();
      return 0;
  }
  
  void myfunc()
  {
      vector&lt;A*&gt; vec;
      vec.push_back(new A(1));
      vec.push_back(new A(2));
  }
  </code></pre>
  
  <p>according to what i read, when variable vec goes out of scope in myfunc(), it should destruct its contained elements, so the destructor for A should be called. I have a breakpoint at ~A(), but never gets called, i have tried resize(), erase methods also </p>
  
  <p>TIA</p>