Originale-mail to me for new edition

 

Forward declarations

 

An interface declaration that ends with the reserved word interface and a semicolon, without specifying an ancestor, GUID, or member list, is a forward declaration. A forward declaration must be resolved by a defining declaration of the same interface within the same type declaration section. In other words, between a forward declaration and its defining declaration, nothing can occur except other type declarations.

Forward declarations allow mutually dependent interfaces. For example,

type

  IControl = interface;

  IWindow = interface

    ['{00000115-0000-0000-C000-000000000044}']

    function GetControl(Index: Integer): IControl;

    ...

  end;

  IControl = interface

    ['{00000115-0000-0000-C000-000000000049}']

    function GetWindow: IWindow;

    ...

  end;

Mutually derived interfaces are not allowed. For example, it is not legal to derive IWindow from IControl and also derive IControl from IWindow.

 

Topic groups

 

See also

Interface types: Overview

Object interfaces: Overview

 

 

译文

 

向前声明

 

接口声明以保留字interface和一个分号结束,没有指定祖先、GUID或成员列表,这样的声明是一个向前声明(forward declaration)。接口的向前声明必须在相同的类型声明节中被同一接口的定义声明(defining declaration)解析。换句话说,在向前声明极其定义声明之间,除了其他的类型声明之外,不能有任何其他内容。

向前声明允许接口相互依赖。例如,

type

  IControl = interface;

  IWindow = interface

    ['{00000115-0000-0000-C000-000000000044}']

    function GetControl(Index: Integer): IControl;

    ...

  end;

  IControl = interface

    ['{00000115-0000-0000-C000-000000000049}']

    function GetWindow: IWindow;

    ...

  end;

相互起源的接口是不允许的。例如,IWindow起源于IControl并且IControl又起源于IWindow,这是不合法的。

 

主题组

 

相关主题

接口类型:概述

对象接口:概述