Wednesday, September 1, 2010

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

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 main difference:
A copy constructor has no return type, whereas an
overloaded assignment operator has one.

Third difference (trivial):
Name of the copy constructor is the same as that of the
class in which it is defined

No comments:

Post a Comment