Had a friend of mine point out the wonderful C++ feature of pure virtual destructors.
I.e.
class X
{
public:
~X() = 0;
}
X::~X() {}
This is apparently legal C++ (Sect 10.3 and 10.4). It seems counter intuitive and yet apparently serves a purpose. If no other methods of a class are abstract, a virtual destructor can be used to prevent the instantiation of the class.
As well, it seems it is legal to provide a definition of any pure virtual function. Thus the meaning of a pure virtual method is that it prevents the instantiation of a class and that all pure virtual methods, minus the destructor, can be optionally defined.
This is a slight conceptual difference than what I had thought of pure virtual functions. In practice I have never defined a pure virtual function. And the notion of defining a pure virtual destructor is disturbing. I really believe that explicitly declaring and definition constructors as protected conveys the intent much clearer than a pure virtual destructor ever could.
Sometimes I wonder how stuff like this ever gets into standards.
