1.

What happens when an object is passed by reference?(a) Destructor is not called(b) Destructor is called at end of function(c) Destructor is called when function is out of scope(d) Destructor is called when called explicitlyThe question was posed to me in final exam.Query is from Destructors in chapter Constructors and Destructors of Object Oriented Programming

Answer»

Right option is (a) Destructor is not called

The best I can explain: The destructor is never called in this situation. The CONCEPT is that when an object is passed by REFERENCE to the function, the CONSTRUCTOR is not called, but only the main object will be used. Hence no destructor will be called at end of function.



Discussion

No Comment Found

Related InterviewSolutions