Home > Back-end >  ~ ~ ~ about generic types TList <> assignment of doubt, consult ~ ~ ~
~ ~ ~ about generic types TList <> assignment of doubt, consult ~ ~ ~

Time:09-16

The following is a simple example;

Type
TR=record
Num: Integer;
end;
TL2=TList;

TL1=TList

Procedure Init ();
Var
L1: TL1;
L2: TL2;
R: TR.
I: Integer;
The begin
L1:=TL1. Create;
For I:=0 to 10 do
The begin
R.N um:=I;
L2:=TL2. Create;
L2. Add (R);
L1. Add (L2);
end;
end;

L2 this variable, not in L1. Add after release, the L2 repeatedly Create let me very uneasy, refer to this correct?

CodePudding user response:

Don't have a minute, can only send this, sorry!

CodePudding user response:

List of list the data types are relatively rare,
And L2 list only a data,

CodePudding user response:

L2 cannot be released, of course, L1. The Add (L2), L1 to L2 management, L1 released, automatic release all L2 (the default)

CodePudding user response:

Sorry, wrong, the LIST there is no automatic management, TobjectList automatic management,
This and similar LIST to add Pointers, L1 released, circulation first release L2

CodePudding user response:

Thank you for your answer, upstairs, indeed, the last cycle release L2, then release the L1 can, thank you very much
  • Related