[Lazarus] IUnknown and reference counting

Sven Barth pascaldragon at googlemail.com
Wed Mar 20 16:22:17 CET 2013


Am 20.03.2013 15:35, schrieb Xiangrong Fang:
> OK, What confused me is the description found in FPC manual saying:
>
> TInterfacedObject is a descendent of TObject 
> <http://www.freepascal.org/docs-html/rtl/system/tobject.html> which 
> implements the IUnknown 
> <http://www.freepascal.org/docs-html/rtl/system/iunknown.html> 
> interface. It can be used as a base class for all classes which need 
> reference counting.
>
> in another word, reference counting is a feature of TInterfacedObject, 
> or the AfterConstruction/BeforeDestruction methods??  it sounds like 
> non-descedants of TInterfacedObject are not reference counted??
No, the reference counting is a feature of IUnknown (or any descendant 
of it) and is only used if you work with the interface and not the class 
type. You can implement the IUnknown (or IInterface) interface yourself 
as well.

Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20130320/a3e64213/attachment-0003.html>


More information about the Lazarus mailing list