1.

The arguments to a copy constructor _____________(a) Must be const(b) Must not be cosnt(c) Must be integer type(d) Must be staticThis question was addressed to me in an online quiz.The origin of the question is Copy Constructor in division Constructors and Destructors of Object Oriented Programming

Answer»

The CORRECT ANSWER is (a) Must be const

To explain I would say: The object should not be modified in the copy CONSTRUCTOR. Because the object itself is being copied. When the object is RETURNED from a function, the object must be a CONSTANT otherwise the compiler creates a temporary object which can die anytime.



Discussion

No Comment Found

Related InterviewSolutions