------=_NextPart_000_0023_01BD63FA.42B824A0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Hello,=20
Fred Gray has recently informed me of the procedure by which destructors =
are called and the difference between virtual and non virtual =
destructors implementation. Apparently for non virtual destructors, all =
inherited base destructors are called up to the level of the pointer =
type passed to delete. Whereas with virtual destructors, all inherited =
base destructors are called up to the level of the instantiated type.
Given the class hierarchy=20
class TCClass : publicTBClass
{
...
}
class TBClass : public TAClass
{
...
}
where
TBClass *b =3D new TCClass;
delete b;
then :
1) if all classes have virtual destructors --> ~TAClass(), =
~TBClass(), ~TCClass
2) if all classes have NON virtual destructors --> ~TAClass(), =
~TBClass()=20
If this is correct, shouldn't root classes (such as TObject or any root =
class allowed to be inherited) have their destructors implemented as =
virtual? =20
William J Deninger
------=_NextPart_000_0023_01BD63FA.42B824A0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD W3 HTML//EN">