title: Assignment operator and Copy Constructor
body: <p>I had recently asked a question somewhat related to this one, but it was horridly worded and I had no clue what I was doing. I got some time to play around with code and hope this question makes more sense. Nevertheless something is still going on wrong. I have a class B. A pointer (*p) to that class. I just want to make a copy of this pointer ( say called q). Delete p but still have q a valid pointer pointer to that same information that p was pointings too. Then delete q. When I try to set them equal to each other I get issues</p>
  
  <pre><code>class B
  {
      public:
      B(); ~B();
      B(const B &amp;Overloading);
      B&amp; B::operator=(const B &amp;Overloading);
      vector&lt;*A&gt; stores_a; //class A contains ints, doubles etc. I filled this with
      //pointers to class A
      void Mr_Clean();
  };
  
  B::B() {}
  ~B::B()
   {
      Mr_Clean();
   }
   B::B(const B &amp;Overloading)
   {
       for(size_t i=0; i&lt;stores_a.size(); i++)
       {
           stores_A[i]=new A(*Overloading.stores_a[i]);
       }
    }
  B::B&amp; B::operator=(const B &amp;Overloading)
    {
        if(this!=&amp;Overloading)
        {   Mr_Clean(); 
            for(size_t i=0; i&lt;stores_a.size(); i++)
            {
                stores_A[i]=new A(*Overloading.stores_a[i]);
             }
        }
        return *this 
   }
   void B::Mr_Clean()
   {
      for(size_t i=0; i&lt;stores_A.size(); i++)
      {
          delete stores_A[i];
      }
   }
   int main()
   {
         B *p=new B;
         B *q=new B;
         // fill some stuff. this is just random stuff I am making up
         *q=*p; //compiles then Kaboom at this line
          delete p;
          delete q;
        return 0;
    }
  </code></pre>
  
  <p>I guess I have some conceptual gap still on the assignment operator. I have read many tutorials and I feel like I am doing what they say...</p>
  
  <p>Also another question, say in this example I also had a member int x in B. Since I called the copy constructor and overloaded the assignment operator do I have to explicitly call x=Overloading.x? I mean technically I am overriding the default copy constructor no? However x is just a regular plain old int. </p>