first of all, I want an answer in details if u dont mind..

When we use a class with Pointer data members,why do we need to:

  1. include a destructor and a copy constructor in the class
  2. overload an assignment operator which return pointer this

for example:

         // function definition
         const className& className::operator=(const className& Object)
              //local declaration
              if(this != &Object)
                   //algorithm to copy Object into this object
                  //return the object assigned
               return *this;

can we use the other object name instead of pointer this just to assign the values?

thanks for your time..^^..

Edited by Reverend Jim: Fixed formatting

6 Years
Discussion Span
Last Post by group256

Please use [code] around your code section to make it easier both to read, trace and copy and paste to editors.

You can easily obtain all the first question in almost any Object oriented programming or C++ programming book. That's why I think this post has received Negative points. You should ask something that you can't (or at least can't easily) find online.

Please take a look at this for more information.


This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.