Question #4704

What is the difference between a copy constructor and an overloaded assignment operator?

Expert's answer

At first, a copy constructor constructs a new object by using the content of the argument object. An overloaded assignment operator assigns the contents of an existing object to another existing object of the same class.
Second, a copy constructor has no return type, whereas an overloaded assignment operator has one.
And the third: name of the copy constructor is the same as that of the class in which it is defined.
LATEST TUTORIALS
APPROVED BY CLIENTS