Hi,

I am writing a Tree class which have the following skeleton:

generic TTree<T> = class
private
  FItems: TList;
public
  ...
end;

The FItems variable is used to store Children of current node.  My question
is:

Shall I store  TTree in FItems or @TTree?  My understanding is:

If a variable obj is an TObject,  it is actually a pointer, which stores
the address of the "real" object structure.

If I add @obj into FItems, then I am storing the address of the obj
variable, i.e.:

FItems[i] --> obj --> (real object structure)

However, if I add obj into FItems, I am storing the address of the object
structure, i.e.:

FItems[i]  -----> (real object structure)
                   ^
                   |
                  obj


Is that correct?  In the 2nd case, is there any "reference counter" for
TObject which counts how many "pointers" are pointing to the structure?

Thanks.
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to