1.

Copy constructor definition requires __________________(a) Object to be passed by value(b) Object not to be passed to it(c) Object to be passed by reference(d) Object to be passed with each data member valueThis question was addressed to me in exam.I want to ask this question from Passing Object to Functions in section Assigning Object, Pointer to Objects, Passing and Returning Object of Object Oriented Programming

Answer»

Correct OPTION is (c) OBJECT to be passed by reference

Easy explanation - The object MUST be passed by reference to a copy constructor. This is to avoid the out of memory ERROR. The constructors keeps calling itself, if not passed by reference, and GOES out of memory.



Discussion

No Comment Found

Related InterviewSolutions