Difference between a "assignment operator" and a "copy constructor"

Difference between a "assignment operator" and a "copy constructor"

many diff are there :
> Copy constructor copies a existing object to a non existing object, which we are going to create. Assignment operator can happen between two existing objects.
> copy constructor creates shallow copy assignment operator creates deep copy.
> Assignment operator assign the value of one object to another aftr the 1st object is fully created but in copy constructor it assign the value of one object to another at the time of its creation.
> Copy constructor donot return anything. Assignment operator returns object of same type.
> Copy constuctor initialize the object with the another object of same class whereas assignment operator can be called on objects of different classes .

By:UMANG
Date:2001-01-09 00:00:00

Post Your Answers


User Email:

User Name:
Answers:

Related C Subjective Links

C Subjective interview questions and answers for experienced and fresher