1.

Which option is best to eliminate the memory problem?(a) use smart pointers(b) use raw pointers(c) use virtual destructor(d) use smart pointers & virtual destructorThis question was addressed to me in an interview.This key question is from Large Objects in chapter Source Files, Classes and Operator Overloading in C++ of C++

Answer» RIGHT OPTION is (d) USE smart POINTERS & virtual destructor

Explanation: Virtual destructor means is that the object is destructed in reverse order in which it was constructed and the smart pointer will delete the object from memory when the object goes out of scope.


Discussion

No Comment Found

Related InterviewSolutions