请问各位高手关于一个指针的问题,代码如下:
PCellData = ^TCellData;
TCellData = Record
id: string;
name: string;
end;var
i, n: integer;//i, n的值从另处得
vcell: array of PCellData;
begin
setlength(vcell, n);
for i := 0 to n - 1 do
begin
new(vcell[i]);
......
end;
end;
我在退出程序时出现错误提示,Invalid pointer Opration,这是什么回事呀,是不是指针没有释放。请各位帮小弟一把。谢谢。
PCellData = ^TCellData;
TCellData = Record
id: string;
name: string;
end;var
i, n: integer;//i, n的值从另处得
vcell: array of PCellData;
begin
setlength(vcell, n);
for i := 0 to n - 1 do
begin
new(vcell[i]);
......
end;
end;
我在退出程序时出现错误提示,Invalid pointer Opration,这是什么回事呀,是不是指针没有释放。请各位帮小弟一把。谢谢。
你没有贴后面的代码 具体的我不是很清楚 但是
下面代码
Type
PCellData = ^TCellData;
TCellData = Record
id: string;
name: string;
end;var
i, n: integer;
vcell: array of PCellData ;
begin
n:=2;
setlength(vcell, n);
for i := 0 to n-1 do
begin
new(vcell[i]);
vcell[i].id:='1';
showmessage(vcell[i].id )
end;
end;但是我这里运行 非常正常 不知道你哪里是什么情况 我估计是你的数组越界了
比如:vcell是临时变量,这个过程完了,他就自动给你释放了(变体数组)
而你在其他地方又用到过它,