[fpc-pascal] why constructor of TObject is NOT virtual but destructor is?

Xiangrong Fang xrfang at gmail.com
Mon May 5 04:12:21 CEST 2014


Hi All,

I would like to know the benefit of making constructor / destructor
virtual.  As described here:

http://c2.com/cgi/wiki?VirtualConstructor

The benefit of virtual constructor seems related to "class reference". As
far as I understand, it is related to how LCL works, like:

CreateComponent(AComponent: TComponentClass);

My questions are:

1) if the above understanding is correct AND COMPLETE, why the constructor
of TObject is not virtual? What problem will appear IF we make it virtual?

2) What is the purpose of making destructor of TObject virtual?

Thanks!

Xiangrong
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20140505/3e5df603/attachment.html>


More information about the fpc-pascal mailing list