[prog] C++ inheritance - destructors

Jimen Ching jching at flex.com
Tue May 27 21:49:19 EST 2003


On Tue, 27 May 2003, Kathryn Hogg wrote:
>If a derived class doesn't explicitly call a constructor for a base class,
>the default constructor for the parent class.  In fact, the constructors
>for the parent classes will be called from the ground up.   For example,
>if you have a base class Vehicle and Car inherits from it, during the
>construction of a Car, it becomes a Vehicle and then becomes a Car.

I should add that the virtual base class must be initialized by the most
derived class.  In other words, you can't expect intermediate base classes
to initialize its own base class.  This is a non-obvious behavior that I
discovered when I started C++ programming.

--jc
-- 
Jimen Ching (WH6BRR)      jching at flex.com     wh6brr at uhm.ampr.org


More information about the Programming mailing list