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
What is a flag in c++?
Which field is used in c++?
explain the reference variable in c++?
What is meaning of in c++?
Can we make copy constructor private in c++?
How do you declare A pointer to a function which receives nothing and returns nothing
What does ctime() do?
Write a Program for find and replace a character in a string.
What is the type of 'this' pointer?
What is the use of "new" operator?
Name four predefined macros.
Why c++ is not a pure oop language?
How do you traverse a btree in backward in-order?
What is dev c++ used for?
Discussion on error handling of C++ .