When does a class need a virtual destructor?
Page 1 of 1
When does a class need a virtual destructor?
If your class has at least one virtual function, you should have a virtual destructor. This allows you to delete a dynamic object through a baller to a base class object. In absence of this, the wrong destructor will be invoked during deletion of the dynamic object.
Similar topics
» What is a virtual destructor? Explain the use of it.
» What is Virtual base class? Explain its uses.
» What is virtual function? Explain with an example
» What are pure virtual functions?
» What is virtual constructors/destructors?
» What is Virtual base class? Explain its uses.
» What is virtual function? Explain with an example
» What are pure virtual functions?
» What is virtual constructors/destructors?
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum