The pure virtual destructor is possible in C++. If a class contains pure virtual destructor it is must to provide a function body for the pure virtual destructor.
Example Code
#include <iostream>
using namespace std;
class B {
public:
virtual ~B()=0; // Pure virtual destructor
};
B::~B() {
std::cout << "Pure virtual destructor is called";
}
class D : public B {
public:
~D() {
cout << "~D() is executed"<<endl;
}
};
int main() {
B *bptr=new D();
delete bptr;
return 0;
}Output
~D() is executed Pure virtual destructor is called