![]() ![]() Specify interface methods and properties here. Syntax Example: //Language interface: //Interface section of unit. Then implement in all classes that support the interface. Since interfaces, by definition, do not have any implementation details, all you do is specify it in the type block. 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. Descending from IUnknown instead of IInterface informs the Delphi compiler that the interface must be compatible with COM objects - a Windows feature). Then have your implementing class inherit from TInterfacedObject and implement the interface.įor 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).įor a com object, you descend from IUnknown. In Delphi, you use interfaces for both com objects and language interfaces and make use of IUnknown, IInterface, and/or TInterfacedObject.įor 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. For example, it is not legal to derive IWindow from IControl and also derive IControl from IWindow."Interfaces" IInterface, TInterfacedObject Mutually derived interfaces are not allowed. Here is an example of an interface declaration: Since interfaces do not implement their own methods, these designations have no meaning. Methods cannot be declared as virtual, dynamic, abstract, or override.They cannot be instantiated, except through classes that implement their methods. Interfaces have no constructors or destructors.(But an array property can be declared as default.) Visibility specifiers and storage specifiers are not allowed. All members of an interface are public. ![]() ![]() Since an interface has no fields, property read and write specifiers must be methods.The memberList can include only methods and properties.In most respects, interface declarations resemble class declarations, but the following restrictions apply: If your interface is to be accessed through COM, be sure to specify the ancestorInterface and GUID. How that will be accomplished alongside new support for multiple inheritance of interfaces has not been decided. Delphi 8 will still have to support the 'denial of ancestors' policy to work around OLE2 bugs such as IClassFactory/IClassFactory2 behavior. Warning: The ancestorInterface and GUID specification are required to support Win32 COM interoperability. Multiple inheritance for Interfaces will also be implemented in the dcc32 compiler for Delphi 8. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |