Type TTudi=class(TObject)
private
FOwner:TComponent;
FDWBH: String;
procedure SetDWBH(const Value: String);
protected
public
Property DWBH:String read FDWBH write SetDWBH; //定义属性
constructor Create(OWner:TObject);overload;
destructor Destroy;
procedure Add; {增加}
procedure free //??可否这么定义??
end;yluo:TTudi;
如果我有程序反复执行以下代码
yluo:=Tyluo.Create(panel1);
yluo.Listyluo;
在没有yluo.Free;或yluo.destory;的情况下,程序会受什么影响?
而在一般情况下,我们都使用yluo.Free来释放,如果我想在free中加一些代码,则把free定义成一个过程?还是象destructor Destroy;那样,写成destructor free;
private
FOwner:TComponent;
FDWBH: String;
procedure SetDWBH(const Value: String);
protected
public
Property DWBH:String read FDWBH write SetDWBH; //定义属性
constructor Create(OWner:TObject);overload;
destructor Destroy;
procedure Add; {增加}
procedure free //??可否这么定义??
end;yluo:TTudi;
如果我有程序反复执行以下代码
yluo:=Tyluo.Create(panel1);
yluo.Listyluo;
在没有yluo.Free;或yluo.destory;的情况下,程序会受什么影响?
而在一般情况下,我们都使用yluo.Free来释放,如果我想在free中加一些代码,则把free定义成一个过程?还是象destructor Destroy;那样,写成destructor free;
普通的VCLfree实现过程就是
begin
if 实例<>nil then//多是否为空的验证,防止destroy时该实例发生意外错误
实例.destroy;
end;
所以可以加入自己的free定义.