Explain what type of copy the default assignment operator does-00366

Online Quiz This subjective question is related to the book/course vu cs201 Introduction to Programming. It can also be found in vu cs201 Mid Term Solved Past Paper No. 6.

Question 1: Explain what type of copy the default assignment operator "'=" does when applied to objects. (shallow copy or deep copy)
Answer:
if our class has any data member using dynamic memory then we had to write our own code for default constructor, copy constructor and similarly assignment operator as compiler generated version of these functions performs shallow copy that creates dangling pointer, and memory leakage issues in case of dynamic memory allocation. (Page 147)

Choose an organization

Theme Customizer

Gaussian Texture



Gradient Background