请问这两种动态数组的声明有什么不同? 我想是这样的吧,放在public区时因为公共申明,故在关闭时不能自动释放,改为在单元的var MainForm:TForm 后面,则窗体结束时会默认释放.所以会发生你出现的错误了 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 检查有没有指针越界,对于静态数组可以生存期自动管理内存,但是动态数组在关闭窗体前是要释放空间的。可以用如下语句:A:=NIL; B:=NIL; 动态数组要释放空间,如:A:=Nil;或者可能是数组越界。 我测了一下,好像没有你所说的问题,你可以查一下,是不是别的问题。动态数组在DELPHI里是生存期自管理的,离开作用域时会自己释放。 动态数组是自己管理内存的;如果你申请的是基本类型的数组,应该是没有问题的,问题出在别处;如果数组中的元素是由create创建的,很有可能出错! 肯定是其他问题,我这里试了一下,没有问题啊unit Unit1;interfaceuses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;type TForm1 = class(TForm) Button1: TButton; procedure Button1Click(Sender: TObject); private { Private declarations } public aints : array of integer; end;var Form1: TForm1;implementation{$R *.DFM}procedure TForm1.Button1Click(Sender: TObject);begin SetLength(aints,10); aints[1] :=5;end;end. 肯定是其他问题,我这里试了一下,没有问题啊unit Unit1;interfaceuses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;type TForm1 = class(TForm) Button1: TButton; procedure Button1Click(Sender: TObject); private { Private declarations } public aints : array of integer; end;var Form1: TForm1;implementation{$R *.DFM}procedure TForm1.Button1Click(Sender: TObject);begin SetLength(aints,10); aints[1] :=5;end;end. 肯定是其他问题,我这里试了一下,没有问题啊unit Unit1;interfaceuses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;type TForm1 = class(TForm) Button1: TButton; procedure Button1Click(Sender: TObject); private { Private declarations } public aints : array of integer; end;var Form1: TForm1;implementation{$R *.DFM}procedure TForm1.Button1Click(Sender: TObject);begin SetLength(aints,10); aints[1] :=5;end;end. 非常感谢大家的帮忙,我又仔细的检查了代码,还真是动态数组出现了越界访问,问题解决了,送分!---mattus_zhao SOCKET编程,高手请进 cxDBPivotGrid如何导出EXCEL?? 调用外部EXE中的导出函数 报错。。。。。。 关于Delphi的一道图形题 请教一个简单存储过程的写法! 有招兼职程序员的吗-广州? 如何屏蔽SQL语句里的特殊字符,如括号,星号(*)等? 不是问题 不是自己 任何都不是~~ 我們的程序要對sql語句分析,得出這個語句要對數據庫進行哪些動,作然後在一個表中保存這些分析結果。請大家給些思路怎樣做會考慮全面點!!! 好久没来 问个问题 请问在Delphi中如何添加一个资源文件,并把一个图片加到这个资源文件中。 大家对这个问题感兴趣吗?方正当初为什么抛弃金山?
B:=NIL;
或者可能是数组越界。
动态数组在DELPHI里是生存期自管理的,离开作用域时会自己释放。
如果数组中的元素是由create创建的,很有可能出错!
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
aints : array of integer;
end;var
Form1: TForm1;implementation{$R *.DFM}procedure TForm1.Button1Click(Sender: TObject);
begin
SetLength(aints,10);
aints[1] :=5;
end;end.
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
aints : array of integer;
end;var
Form1: TForm1;implementation{$R *.DFM}procedure TForm1.Button1Click(Sender: TObject);
begin
SetLength(aints,10);
aints[1] :=5;
end;end.
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
aints : array of integer;
end;var
Form1: TForm1;implementation{$R *.DFM}procedure TForm1.Button1Click(Sender: TObject);
begin
SetLength(aints,10);
aints[1] :=5;
end;end.