我已经编写Delphi程序五六年了,自认为还算比较擅长,但最近遇到一个行为问题却无法解释。我在编写一个简单的链表(叫做TIntegerList)时发现以下示例代码可以正确编译:
type
PIntegerValue = ^TIntegerValue;
TIntegerValue = record
Value: Integer;
Next: PIntegerValue;
Prev: PIntegerValue;
end;
然而,下面的代码不行(提示TIntegerValue未声明):
type
PIntegerValue = ^TIntegerValue;
type
TIntegerValue = record
Value: Integer;
Next: PIntegerValue;
Prev: PIntegerValue;
end;
在Delphi中,“type”关键字的处理方式是什么?在一个“type”关键字下声明多个类型与每个类型声明一个“type”关键字相比,语法上有何意义?好吧,这很困惑,但我希望代码示例可以帮助解释我的意思。我正在使用Delphi 2007。
Pointer Types
有以下说明:“注意:您可以在声明所指向的类型之前声明指针类型。” - LU RD