Sign in Join
Wiki copytemporary

Basic Pascal Tutorial/Chapter 4/Forward Referencing/zh CN: what changed

Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.

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

OldNewLine
1+4F - 前向引用 (原作者: Tao Yue, 状态: 未更改)
2+
3+这些虽然容易理解,但有时也让人困惑。
4+
5+程序中只能使用已经定义的过程/函数?或许是这样吧,先定义后使用。
6+
7+不过,也有例外,你想先使用后定义?要解决这类问题,你需要使用*前向引用*。(在预先声明的过程/函数后加*forward*)
8+
9+如:
10+
11+``` pascal
12+procedure Later (参数列表); forward;
13+
14+procedure Sooner (参数列表);
15+begin
16+ ...
17+ Later (参数列表);
18+end;
19+...
20+procedure Later;
21+begin
22+ ...
23+ Sooner (参数列表);
24+end;
25+```
26+
27+示例:
28+
29+``` pascal
30+program q;
31+
32+procedure a;forward;
33+
34+procedure b;
35+begin
36+ writeln('B调取A:');
37+ a;
38+end;
39+
40+procedure a;
41+begin
42+ writeln('A过程.');
43+end;
44+
45+begin
46+ b;
47+end.
48+```
49+
50+### 相关
51+
52+[维基百科前向声明](https://zh.wikipedia.org/wiki/%E5%89%8D%E5%90%91%E5%A3%B0%E6%98%8E)
53+
54+| | | |
55+|----|----|----|
56+| [[Basic Pascal Tutorial/Chapter 4/Recursion/zh CN|上一页]] | [[Basic Pascal Tutorial/Contents/zh CN|目录]] | [[Basic Pascal Tutorial/Chapter 4/Programming Assignment/zh CN|下一页]] |
57+
58+---
59+*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](/wiki-contact).*

Back to history