On 2010-06-17 20:11, Robert Bieber wrote:

You are correct, I should be making them virtual (I'll go and fix that
shortly). Strictly speaking, it isn't an issue unless you declare
children of a class that has a non-virtual destructor. The compiler will
always ensure that all parent-class destructors are called in order at
destruction, but if you inherit from a class that has a non-virtual
destructor, and then you delete a pointer to the base class which is
also an instance of the child class, the child class' constructor won't
be called. Now that someone else has mentioned it, I do think that
having the original base class constructor virtual makes all the
following destructors virtual, but it's still safest to just explicitly
declare them all that way.

According to the C++ FAQ Lite, the destructor is automatically virtual if the base class destructor is. See here for details:

http://www.parashift.com/c++-faq-lite/virtual-functions.html#faq-20.7

--
  Magnus

Reply via email to