Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

Is there a fundamental different between the copy constructor and the assignment operator?

0
Posted

Is there a fundamental different between the copy constructor and the assignment operator?

0

Yes, there is. Although the copy constructor and the assignment operator have similar functions, they differ in one crucial aspect. A copy construction operation is a constructor call by all means. That is, the object being constructed during a copy constructor invocation has an indeterminate state until the copy constructor has returned successfully. Furthermore, a copy constructor doesn’t return any value (not even void) — very much like any other constructor whereas an assignment operator has a return value. A copy constructor will be called only when a new object is being instantiated. The assignment operator is called for an existing object to which a new value is being assigned.

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123