|Navigation: Language Reference > 4 - Entity Declarations > Complex Data Structures >====== INTERFACE (class behavior definition) ======|
|label||INTERFACE ( [ parentinterface ] )||[, TYPE] [, COM]|
|INTERFACE||A collection of methods to be used by the class that implements the interface.|
|parentinterface||The label of a previously declared INTERFACE structure whose methods are inherited by the new INTERFACE. This may be an INTERFACE with the TYPE attribute.|
|TYPE||Specify the INTERFACE is only a type definition. TYPE is implicit on an INTERFACE but may be explicitly specified.|
|COM||Specify that all methods defined in the interface use a PASCAL calling convention. Used for COM implementation.|
An INTERFACE is a structure, which contains the methods (PROCEDUREs) that define the behavior to be implemented by a CLASS. It cannot contain any property declarations. All methods defined within the INTERFACE are implicitly virtual. A period or the END statement must terminate an INTERFACE structure.
Derived INTERFACEs (Inheritance)
An INTERFACE declared with the parentinterface parameter creates a derived interface that inherits all the methods of the named parentinterface. The derived interface may also contain its own methods.
Any method prototyped in the derived interface with the same name as a method in the parentinterface overrides the inherited method if both have the same parameter lists. If the two methods have different parameter lists, they create polymorphic functions in the derived interface that must follow the rules of Procedure Overloading.
See also the Implementing INTERFACEs in Derived Classes topic for more detailed information regarding this section.
VIRTUAL Methods (Polymorphism)
All methods in an INTERFACE are implicitly virtual, although the virtual attribute may be explicitly specified for clarity.
The PROCEDURE definition of a method (its executable code, not its prototype) is defined by the CLASS that is implementing the INTERFACE. All methods for an interface must be defined in the IMPLEMENTING class.
Referencing INTERFACE methods in your code
You must call the methods of an INTERFACE by using dot notation syntax (by prepending the label of the CLASS to the label of the INTERFACE to the label of the method).
For example, using the following INTERFACE and CLASS declaration:
You may call the MyProc PROCEDURE as: