1.

What is the difference between a Copy Constructor and an Assignment Operator?

Answer»

Though both of them perform similar tasks, the DIFFERENCES between a COPY Constructor and an assignment operator is as follows:

  • While the former is an overloaded Constructor the latter is a Bitwise Operator.
  • The Copy Constructor can be used to initialize a new object with an EXISTING object which is an overloaded Constructor while an assignment operator is invoked only when an object is being assigned to another object.
  • An assignment operator RETURNS a VALUE by default unlike a Copy Constructor. Both of them perform shallow copying by default. An overloaded assignment operator can be used to do deep copying.


Discussion

No Comment Found