1.

Can a copy constructor be made private?(a) Yes, always(b) Yes, if no other constructor is defined(c) No, never(d) No, private members can’t be accessedI had been asked this question at a job interview.The doubt is from Copy Constructor topic in section Constructors and Destructors of Object Oriented Programming

Answer»

The correct choice is (a) Yes, always

Easy explanation - The copy CONSTRUCTOR can be defined as private. If we make it private then the OBJECTS of the class can’t be copied. It can be used when a class used DYNAMIC memory allocation.



Discussion

No Comment Found

Related InterviewSolutions