adspace


What is a copy constructor? What is the need for it?

Answer Posted / Sudeep Kumar

A copy constructor is a special member function in C++ used to create a new object by copying an existing one. It's needed because when we use the assignment operator (=) or pass objects as arguments to functions, the original object might get modified, and a copy of the object is required. The copy constructor ensures that a new object is created with the same state as the original.

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

No New Questions to Answer in this Category !!    You can

Post New Questions

Answer Questions in Different Category