Quick start manual
Object interfaces
10-1
Chapter
10
Chapter10
Object interfaces
An object interface—or simply interface—defines methods that can be implemented by
a class. Interfaces are declared like classes, but cannot be directly instantiated and do
not have their own method definitions. Rather, it is the responsibility of any class that
supports an interface to provide implementations for the interface’s methods. A
variable of an interface type can reference an object whose class implements that
interface; however, only methods declared in the interface can be called using such a
variable.
Interfaces offer some of the advantages of multiple inheritance without the semantic
difficulties. They are also essential for using distributed object models (such as
CORBA and SOAP). Using a distributed object model, custom objects that support
interfaces can interact with objects written in C++, Java, and other languages.
Interface types
Interfaces, like classes, can be declared only in the outermost scope of a program or
unit, not in a procedure or function declaration. An interface type declaration has the
form
type interfaceName = interface (ancestorInterface)
['{GUID}']
memberList
end;
where (ancestorInterface) and ['{GUID}'] are optional. In most respects, interface
declarations resemble class declarations, but the following restrictions apply.
•The memberList can include only methods and properties. Fields are not allowed in
interfaces.
• Since an interface has no fields, property read and write specifiers must be
methods.