Rockbox mail archiveSubject: Re: Destructors in Theme Editor: virtual or non virtual?
Re: Destructors in Theme Editor: virtual or non virtual?
From: Magnus Holmgren <magnushol_at_gmail.com>
Date: Thu, 17 Jun 2010 20:51:17 +0200
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:
-- MagnusReceived on 2010-06-17