1.

How to overcome the problem arising due to destruction of temporary object?(a) Overloading insertion operator(b) Overriding functions can be used(c) Overloading parenthesis or returning object(d) Overloading assignment operator and defining copy constructorI got this question in semester exam.Origin of the question is Passing and Returning Object with Functions topic in division Object of Object Oriented Programming

Answer»

The correct OPTION is (d) Overloading assignment operator and defining copy constructor

Explanation: The problem can be SOLVED by overloading the assignment operator to get the values that might be getting returned while the destructor free the dynamic memory. Defining copy constructor can help us to do this in EVEN simpler way.



Discussion

No Comment Found

Related InterviewSolutions