title: Vector of Deep Copy of pointers
body: <p>I am a very new programmer and a super beginner so I don't know too much about c++. I had specifically a question regarding making deep copies of pointers. What I have is a class A full of POD's and a pointer to this class (A *P).
  I have a second class B which contains some other POD's and a vector of pointers to Class A.
  I want to fill this vector of deep copies of A *P because in a loop I will be dynamically allocating and deallocating it. The following does not work. I believe its my copy constructor and overloading of the = operator. This is something I am doing for fun and learning. </p>
  
  <pre><code>class A
  {
     public:  
     .....
     .....
     .....
  };
  
  class B
  {
     public:  
     B();
    ~B();
     B(const B &amp;Copier);
     B&amp; B::operator=(const B &amp;Overloading);
     vector&lt;A*&gt; My_Container;
     A* Points_a_lot;
     int counter;
   };
  B::B()
  {
    counter=0;
    Points_a_lot=NULL;
  }
  B::~B()
  {
     for(size_t i=0; i&lt;My_Container.size(); i++)
     {
        delete My_Container[i];
      }
   }
   B::B(const B &amp;Overloading)
   {
       My_Container[counter]=new A(*Overloading.Points_a_lot);
   }
   B&amp; B::operator=(const B &amp;Overloading)
   {
       if(!Overloading.My_Container.empty()) 
       {
           Overloading.My_Container[counter]=new B(*Overloading.Points_a_lot);
        }
        return *this; 
    } 
   int main()
   {  A* p=NULL;
      B Alphabet;
      for(....)
      {
          p=new A;
          //some stuff example p-&gt;Member_of_A=3; etc..
          Alphabet.My_Container[Alphabet.counter]=p;
          Alphabet.counter++;
         delete p;
       }
      return 0;
     }
  </code></pre>
  
  <p>Any help will be great. I thank you for your time. Assume needed libraries included. </p>