From RAD Studio API Documentation
Jump to: navigation, search



TInterfacedObject = class(TObject, IInterface)


class PASCALIMPLEMENTATION TInterfacedObject : public TObject


Type Visibility Source Unit Parent
class public
System System


TInterfacedObject is a base for simple classes that need a basic IInterface implementation.

TInterfacedObject is a thread-safe base class for Delphi classes that support interfaces. TInterfacedObject provides basic reference-counting functionality that makes its descendent classes useful in both Delphi and C++ code.

Note: In Delphi, variables declared to be of type TInterfacedObject have dynamic binding, meaning that an instance of a descendent class can be assigned to that variable at run time. This is because TInterfacedObject implements QueryInterface, which is called at run time to query whether the instantiated object supports the requested interface. If it does, the descendent object is successfully assigned to the variable. Without QueryInterface support, such an assignment would produce a compile-time error.

In Delphi, a descendant of TInterfacedObject does not have a class factory or a CLSID. Thus it cannot be instantiated except by calling a constructor.

TInterfacedObject does not implement the methods of the C++ version of IUnknown or IInterface. This is not a problem when using C++ wrappers for TInterfacedObject descendants that are written in Delphi. However, if you are creating C++ descendants of TInterfacedObject, you must provide your own implementation of IUnknown. For information on how to do this, see Creating classes that support IUnknown (supplied with C++ products only).

See Also