Delphi: 'Interfaces' IInterface, TInterfacedObjectIn Delphi, you use interfaces for both com objects and language interfaces and make use of IUnknown, IInterface, and/or TInterfacedObject.For a pure language interface, add your specified proprieties, procedures, and functions to an interface that descends from IInterface (the base interface) as an interface, no implementation. Then have your implementing class inherit from TInterfacedObject and implement the interface.For extending the VCL, you descend from the class you wish to extend, then implement an interface from IInterface and add the required functions QueryInterface, AddRef, and Release methods (refer to TInterfacedObject for an example).For a com object, you descend from IUnknown. Descending from IUnknown instead of IInterface informs the Delphi compiler that the interface must be compatible with COM objects - a Windows feature).When defining an interface, define it in the type block just like you do for a class but you use the interface keyword instead of the class keyword and in the interfaces section only. Since interfaces, by definition, do not have any implementation details, all you do is specify it in the type block. Then implement in all classes that support the interface. Syntax Example: //Language interface: //Interface section of unit.
Tour Start here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site.
IHuman = Interface(IInterface) //Specify interface methods and properties here.end; TCyborg = class( TInterfacedObject) end; TCyborgHuman = class(TCyborg, IHuman)//Specify each here and implement in//implementation section.end.