LucieLastic
Programmer
hi all
I have 2 objects, each containing a TList variable.
ObjA contains the Tlist.create etc and populates the list (say ListA).
ObjB only has a TList variable, say ListB and doesn't do a create as I don't want 2 separate lists;
procedure ObjA.thing;
begin
ObjB.DoSomething(ListA)
end;
in ObjB
procedure ObjB.DoSomething(ListA : TList);
begin
ListB := ListA;
end;
I thought the above assignment would make ListB equal to the same pointer as ListA. I know I'm passing a TList but I also thought that really I'm passing a pointer to a TList. I'm confused.
All I want is ListB's pointer to equal ListA's pointer. The program doesn't fail but I get bits of garbage in the list. What do I need to do?
lou
I have 2 objects, each containing a TList variable.
ObjA contains the Tlist.create etc and populates the list (say ListA).
ObjB only has a TList variable, say ListB and doesn't do a create as I don't want 2 separate lists;
procedure ObjA.thing;
begin
ObjB.DoSomething(ListA)
end;
in ObjB
procedure ObjB.DoSomething(ListA : TList);
begin
ListB := ListA;
end;
I thought the above assignment would make ListB equal to the same pointer as ListA. I know I'm passing a TList but I also thought that really I'm passing a pointer to a TList. I'm confused.
All I want is ListB's pointer to equal ListA's pointer. The program doesn't fail but I get bits of garbage in the list. What do I need to do?
lou