forward [提前声明]

来源:互联网 发布:linux中安装oracle11g 编辑:程序博客网 时间:2024/05/18 23:53

通常只在implementation部分使用。如果两个函数都在implementaion部分实现,而没有在interface部分声明才需要这个关键字。例如FuncA和FuncB要相互调用,为了让FuncA知道有FuncB存在,就在FuncA的前面先声明一次FuncB并加上forward。如果FuncB在interface中声明过了就不再需要了。

function FuncB(a: Integer): Integer; forward;function FuncA(a: Integer): Integer;begin  Result := FuncB(a) + 12;end;function FuncB(a: Integer): Integer;begin  if (a > 99) then Result := 99  else    Result := FuncA(a) + 12;end;