Sign in Join
Wiki copytemporary

Revision 1 of 1, by Kai Burghardt on 8-20-2022. The page as it is now.

Basic Pascal Tutorial/Chapter 4/Forward Referencing/zh CN

4F - 前向引用 (原作者: Tao Yue, 状态: 未更改)

这些虽然容易理解,但有时也让人困惑。

程序中只能使用已经定义的过程/函数?或许是这样吧,先定义后使用。

不过,也有例外,你想先使用后定义?要解决这类问题,你需要使用前向引用。(在预先声明的过程/函数后加forward)

如:

pascal
procedure Later (�数列表); forward;

procedure Sooner (�数列表);
begin
  ...
  Later (�数列表);
end;
...
procedure Later;
begin
  ...
  Sooner (�数列表);
end;

示例:

pascal
program q;

procedure a;forward;

procedure b;
begin
    writeln('B调取A:');
    a;
end;

procedure a;
begin
    writeln('A过程.');
end;

begin
    b;
end.

相关

维基百科前向声明

上一页 目录 下一页

From the Free Pascal wiki, page "Basic Pascal Tutorial/Chapter 4/Forward Referencing/zh CN", as it stood on 2022-08-20 after a change by Kai Burghardt, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's Licensing page. If you have concerns about this material, message the admin.