type
Arec=record Name:string;
Age:integer;
end;
var
p: ^Arec;
i,Num: Integer;
type
ArrPoint = array of Arec;
begin
Num:=4;
p := GetMemory(Num * SizeOf(Arec));
for i := 0 to Num-1 do
begin
ArrPoint(p)[i].Name := '张三'+inttostr(i);
ArrPoint(p)[i].Age :=i+30;
self.Memo1.Lines.Add(ArrPoint(p)[i].Name+',年龄:'+inttostr(ArrPoint(p)[i].Age));
end;
FreeMemory(p);
end;
上面的代码可以在delphi 2007下通过并执行,但在delphi 7下只能通过却无法执行,但即使是在delphi 2007下如果将4改成1000,该段代码也无法执行。
delphi 的指针实在无法恭维,简直就是垃圾!!