![]() |
The IDL specification for a class of objects must contain a declaration of the interface these objects will support.
IDL interfaces and types should be enclosed inside a module scope. IDL declared outside of a module scope takes up namespace in the global IDL namespace and risks having name collisions with names declared by other IDL developers. For more information, see IDL name scoping.
When objects are implemented using classes, the interface name is used as a class name as well. In addition to the interface name and its base interface names, an interface indicates new methods (operations), and any constants, type definitions, and exception structures that the interface exports.
An interface declaration has the following syntax:
interface interface-name [: base-interface1, base-interface2, ...] { constant declarations type declarations exception declarations attribute declarations operation declarations };All of the declaration elements are optional, and their order is not usually significant. However you must bear in mind the following considerations:
- Interface names must be declared before they are referenced.
- Types, constants, and exceptions, as well as interface declarations, must be defined before they are referenced (as in C or C++).
- Using one declaration can mandate another, and determine the order in which they are declared. For example, if an operation raises an exception, the exception must be declared and must come before the operation in the list.
The base-interface names specify the interfaces from which interface-name is derived. Parent-interface names are required only for the immediate base interfaces. Each base interface must have its own IDL specification (which must be #included in the IDL file). A base interface cannot be named more than one time in the interface statement header.
The following topics describe the declaration elements that can be specified within the body of an interface declaration: