1.

Object being passed to a copy constructor ___________(a) Must be passed by reference(b) Must be passed by value(c) Must be passed with integer type(d) Must not be mentioned in parameter listI got this question in my homework.The question is from Copy Constructor in portion Constructors and Destructors of Object Oriented Programming

Answer»

Right answer is (a) Must be passed by REFERENCE

Explanation: This is mandatory to pass the OBJECT by reference. Otherwise, the object will TRY to create another object to copy its values, in turn a constructor will be called, and this will keep on calling itself. This will cause the compiler to give out of memory ERROR.



Discussion

No Comment Found

Related InterviewSolutions