Show: Object Pascal C++
Display Preferences

System.TInterfacedObject

From Appmethod Libraries
Jump to: navigation, search

System.TObjectTInterfacedObject

Object Pascal

TInterfacedObject = class(TObject, IInterface)

C++

class PASCALIMPLEMENTATION TInterfacedObject : public TObject

Properties

Type Visibility Source Unit Parent
class public
System.pas
systobj.h
System System

Description

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

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

Note: In Object Pascal, 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 Object Pascal, 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 Object Pascal. 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

Personal tools
Translations