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..^^..

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.


Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.