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
Reverse the Linked List. Input: 1->2->3->4->5->NULL Output: 5->4->3->2->1->NULL
What is a Default constructor?
What is a v-table?
What is an adaptor class or wrapper class in c++?
What is the average salary of a c++ programmer?
Explain explicit container.
What are references in c++? What is a local reference?
Why was c++ created?
Can I learn c++ as my first language?
What is the best free c++ compiler for windows?
What is srand c++?
State two differences between C and C++.
What is the difference between an enumeration and a set of pre-processor # defines?
How is c++ different from java?
How does atoi function work?