1.

When an object is passed to a function, its copy is made in the function and then ______________(a) The destructor of the copy is called when function is returned(b) The destructor is never called in this case(c) The destructor is called but it is always implicit(d) The destructor must be user definedThe question was posed to me in semester exam.Enquiry is from Destructors topic in division Constructors and Destructors of Object Oriented Programming

Answer» CORRECT option is (a) The destructor of the copy is called when function is returned

The explanation: When an OBJECT is passed to a function, its copy is made in the function. This copy acts as a real object till the function is live. When the function is returned, the copy’s destructor is called to FREE the resources held by it.


Discussion

No Comment Found

Related InterviewSolutions