when can we use virtual destructor?
Answer Posted / n
Virtual Destructor is a concept, comes into picture when one
will try to delete the base object pointer pointing to
derived class.
Base* pb = new Derived();
delete pb;
In this case if Base class destructor is not virtual then
only base class destructor will be called up for clean up.
While if we make Base class destructor as virtual then
1. Derived class destructor will be called
2. Base class destructor will be called up
Proper clean up of the objects from derived as well as base
class. Mission Accomplish
Is This Answer Correct ? | 36 Yes | 1 No |
Post New Answer View All Answers
How do you sort a sort function in c++ to sort in descending order?
What is the use of namespace std in C++?
What is scope operator in c++?
What is the difference between method overloading and method overriding in c++?
What is the difference between equal to (==) and assignment operator (=)?
What is virtual base class?
Which software is best for c++ programming?
Do vectors start at 0?
Differentiate between the manipulator and setf( ) function?
What is a string example?
What are punctuators in c++?
Is swift faster than go?
What are smart pointers?
what are the iterator and generic algorithms.
What is #include cmath?