Delphi 4 にこのコードがあります。タイプのオブジェクトを 10 個作成しT_Charge
(以下を参照)、これをTList
という名前の に追加しましたmyList
。T_Charge
型には、型の 3 つのオブジェクトへの参照があります(T_Platte
以下を参照)。
10 個のオブジェクトすべてのメモリをすべて解放する正しい方法は何ですか? したがって、すべてのオブジェクトについて、、、、などのメモリとそれ自体のメモリP1
を解放したいと考えています。私はすべてについて試しましたが、エラーが発生し続けます。P2
P3
F_Treated
myCharge
procedure Test;
var
myList: TList;
myCharge: T_Charge;
begin
myList := TList.Create;
for i := 0 to 9 do
begin;
myCharge := T_Charge.Create(...);
myList.Add(myCharge);
end;
...
end;
type
T_Platte = class(TObject)
private
F_Nummer : Integer;
F_Los : Integer;
F_Dicke : Real;
F_Lange : Real;
F_Breite : Real;
F_QuenchCode : Integer;
F_Geschwindigkeit : Real;
F_Menge : Integer;
F_MengeInLos : Integer;
F_Treated : Boolean;
public
constructor Create(inNummer, inLos: Integer; inDicke, inLange, inBreite, inGeschwindigkeit : Real; inQuenchCode,inMenge: Integer; inTreated: Boolean); overload;
constructor Create(inPlatte: T_Platte); overload;
destructor Destroy; override;
property Nummer: Integer read F_Nummer write F_Nummer;
property Los: Integer read F_Los write F_Los;
property Dicke: Real read F_Dicke write F_Dicke;
property Lange: Real read F_Lange write F_Lange;
property Breite: Real read F_Breite write F_Breite;
property QuenchCode : Integer read F_QuenchCode write F_QuenchCode;
property Geschwindigkeit: Real read F_Geschwindigkeit write F_Geschwindigkeit;
property Menge: Integer read F_Menge write F_Menge;
property MengeInLos: Integer read F_MengeInLos write F_MengeInLos;
property Treated: Boolean read F_Treated write F_Treated;
function getPlattenRecord: string;
end; // class T_Platte
T_Charge = class(TObject)
private
F_P1 : T_Platte;
F_P2 : T_Platte;
F_P3 : T_Platte;
F_Treated : Boolean;
F_Vmin : Real;
F_Qty : Integer;
F_RelationNext : Boolean;
public
constructor Create(inP1, inP2, inP3 : T_Platte; inTreated: Boolean; inVmin: Real; inQty: Integer; inRelationNext: Boolean); overload;
constructor Create(inCharge : T_Charge); overload;
destructor Destroy; override;
property P1: T_Platte read F_P1 write F_P1;
property P2: T_Platte read F_P2 write F_P2;
property P3: T_Platte read F_P3 write F_P3;
property Treated : Boolean read F_Treated write F_Treated;
property Vmin : Real read F_Vmin write F_Vmin;
property Qty : Integer read F_Qty write F_Qty;
property RelationNext : Boolean read F_RelationNext write F_RelationNext;
function getChargeRecord: string;
end; // class T_Charge
constructor T_Platte.Create(inNummer, inLos: Integer; inDicke, inLange, inBreite, inGeschwindigkeit: Real; inQuenchCode,inMenge: Integer; inTreated: Boolean);
begin
F_Nummer := inNummer;
F_Los := inLos;
F_Dicke := inDicke;
F_Lange := inLange;
F_Breite := inBreite;
F_Geschwindigkeit := inGeschwindigkeit;
F_QuenchCode := inQuenchCode;
F_Menge := inMenge;
F_MengeInLos := 0;
F_Treated := inTreated;
end;
constructor T_Charge.Create(inP1, inP2, inP3 : T_Platte; inTreated: Boolean; inVmin: Real; inQty: Integer; inRelatio nNext: Boolean);
begin
F_P1 := T_Platte.Create(inP1);
F_P2 := T_Platte.Create(inP2);
F_P3 := T_Platte.Create(inP3);
F_Treated := inTreated;
F_Vmin := inVmin;
F_Qty := inQty;
F_RelationNext := inRelationNext;
end;