Ilnterface and Inheritance

An interface, like a class, inherits all of its ancestors' methods. But interfaces, unlike classes, do not implement methods. What an interface inherits is the obligation to implement methods an obligation that is passed onto any class supporting the interface.

The declaration of an interface can specify an ancestor interface. If no ancestor is specified, the interface is a direct descendant of Ilnterface, which is defined in the System unit and is the ultimate ancestor of all other interfaces. On Win32, Ilnterface declares three methods: Queryinterface, _AddRef, and _Release. These methods are not present on the .NET platform, and you do not need to implement them.

Note: ilnterface is equivalent to iUnknown. You should generally use ilnterface for platform independent applications and reserve the use of IUnknown for specific programs that include Win32 dependencies. Queryinterface provides the means to obtain a reference to the different interfaces that an object supports. _AddRef and _Release provide lifetime memory management for interface references. The easiest way to implement these methods is to derive the implementing class from the System unit's TInterfacedObject. It is also possible to dispense with any of these methods by implementing it as an empty function; COM objects, however, must be managed through _AddRef and _Release.

Project Management Made Easy

Project Management Made Easy

What you need to know about… Project Management Made Easy! Project management consists of more than just a large building project and can encompass small projects as well. No matter what the size of your project, you need to have some sort of project management. How you manage your project has everything to do with its outcome.

Get My Free Ebook

Post a comment