Did you know that a destructor can be pure virtual? It can be defined as such, but it still needs a body declaration. It is a way of making a class abstract (instances of it cannot be created) without having to make any pure virtual methods. So use it if you have a base class that you don’t want users to instantiate but you have no other candidates for pure virtual specifier πŸ™‚

Additional discussion of this topic at Geeks for Geeks: Pure virtual destructor in C++.

Complete listing:

2 Replies to “Pure virtual destructor”

Leave a Reply