Respuesta :
... you could overload and implement your assignment operator. They have already been instantiated, so applying a copy constructor is too late I suppose.
Answer:
Any of 2 methods can be used a Deep copy or a Shallow copy
Explanation:
There are 3 ways of copying an object of a class :
1) Shallow copy - This makes copies of all the primitive data type variables but it creates reference to the pointer variable. It means kit doesn't copy them it just creates a new reference to that same address.The default copy constructor and assignment operator make shallow copies.
2) Deep copy - A deep copy copies all member variables, and makes copies of dynamically allocated memory pointed to by the variables. To make a deep copy, we have to define our copy constructor and overload the assignment operator.
Requirements for deep copy in the class :
• A destructor is required to delete the dynamically allocated memory.
• A copy constructor is required to make a copy of the dynamically allocated memory.
• An overloaded assignment operator is required to make a copy of the dynamically allocated memory.