Difference between a copy constructor and an assignment operator - C++

Difference between a copy constructor and an assignment operator.

- Copy constructor creates a new object which has the copy of the original object .
- On the other hand assignment operators does not create any new object. It instead, deals with existing objects.

Difference between a copy constructor and an assignment operator.

- A copy constructor is used to declare and initialize an object from another object.
- Example :
integer I2(I1);
- An assignment operator doesnot invoke the copy constructor. It simply assigns the values of an object to another, member by member.
What is a virtual destructor? Explain the use of it - C++
What is a virtual destructor? Explain the use of it - If the destructor in the base class is not made virtual, then an object that might have been declared of type base class and instance of child class.....
How should a contructor handle a failure?
How should a contructor handle a failure? - Constructors don't have a return type, so it's not possible to use return codes....
What are shallow and deep copy?
What are shallow and deep copy? - A shallow copy just copies the values of the data as they are. Even if there is a pointer that points..
Post your comment
Discussion Board
question correction
what is the copy constructor? answer is that as it can declear the values but also can co[y that constructor into the other class constructor as well when we can inherit it in the other class.......................
adnan ahmed 12-30-2014