<p>Am 05.05.2014 08:04 schrieb "Sven Barth" <<a href="mailto:pascaldragon@googlemail.com">pascaldragon@googlemail.com</a>>:<br>
><br>
> Am 05.05.2014 04:13 schrieb "Xiangrong Fang" <<a href="mailto:xrfang@gmail.com">xrfang@gmail.com</a>>:<br>
> ><br>
> > 2) What is the purpose of making destructor of TObject virtual?<br>
><br>
> The destructor needs to virtual so that the correct one is called no matter what static type a variable has. Imagine you have a TFoo which inherits from TObject and you'd not have a virtual destructor, but only a non-virtual one in both classes. Now if you call Free it would always be TObject.Destroy that is called and not TFoo.Destroy, because Free is declared in TObject and has no way if knowing that there is a TRio descendant that has a constructor as well. And here virtual methods cone to the rescue...</p>
<p>Of course that should have been TFoo at the end, not TRio... Stupid auto completion -.-</p>
<p>Regards,<br>
Sven</p>