小编d.b*_*d.b的帖子

如何释放另一个对象中包含的对象

我正在使用Delphi 2010并且有一个问题是重新释放对象.

假设我有如下代码,如果发生异常,我想清除TProduct和TPart.

如何释放正确包含的对象TPart?

//Clases are defined like this
TProduct = class(TRemotable)
private
  FName: String;
  FAge: Integer;
  FColor: String;
  FPart: TPart;  
published
  property Name: String read FName write FName;
  property Age: Integer read FAge write FAge;
  property Color: String read FString write FString;
  property Part: TPart read FPart write FPart;  
end;

TPart = class(TRemotable)
private
  FName: String;
  FColor: String;  
published
  property Name: String read FName write FName;
  property Color: String read FString write FString;
end;


//Then in a method, code …
Run Code Online (Sandbox Code Playgroud)

delphi oop delphi-2010

-5
推荐指数
1
解决办法
590
查看次数

标签 统计

delphi ×1

delphi-2010 ×1

oop ×1