virtual destructor unexpected pass

Sol Foster colomon@ralf.org
Thu Sep 3 10:50:00 GMT 1998


Martin von Loewis <martin@mira.isdn.cs.tu-berlin.de> wrote:
> Personally, I would have expected that destructors may not be pure,
> and it may seem that they are there 'just for completeness'. So yes,
> I'd agree that they are bad style in most situations.

Pure virtual has a very specific meaning, namely that you can't create a
concrete subclass without overriding that function.  This is every bit as
true for destructors as for any other function.  If you want to force a
derived class to declare a destructor, you declare the base class
destructor to be virtual.  It is a perfectly valid idiom.  (Or, as
someone else said, it's useful if you want to have an abstract base class
but don't have any virtual functions.)

Now, it would be nice if the linker could detect the problem, warn the
user, and tell him to see the C++ FAQ or Effective C++, that would be
nice...



-- 
Sol Foster: colomon@ralf.org

The only thing I like less than a neo-Nazi from Fontana is a Space Nazi
from Hell. 
                                        -Bogie Freedom



More information about the Gcc-bugs mailing list