<div dir="ltr"><div><div><div>Hi,<br><br></div>I am writing a Tree class which have the following skeleton:<br><span style="font-family:courier new,monospace"><br></span></div><span style="font-family:courier new,monospace">generic TTree<T> = class<br>
</span></div><div><span style="font-family:courier new,monospace">private<br></span></div><div><span style="font-family:courier new,monospace"> FItems: TList;<br></span></div><div><span style="font-family:courier new,monospace">public<br>
...<br></span></div><span style="font-family:courier new,monospace">end;<br></span><div><div><br></div><div>The FItems variable is used to store Children of current node. My question is:<br><br></div><div>Shall I store TTree in FItems or @TTree? My understanding is:<br>
<br></div><div>If a variable obj is an TObject, it is actually a pointer, which stores the address of the "real" object structure. <br><br>If I add @obj into FItems, then I am storing the address of the obj variable, i.e.:<br>
<span style="font-family:courier new,monospace"><br>FItems[i] --> obj --> (real object structure)</span><br><br>However, if I add obj into FItems, I am storing the address of the object structure, i.e.:<span style="font-family:courier new,monospace"><br>
<br>FItems[i] -----> (real object structure)<br></span></div><div><span style="font-family:courier new,monospace"> ^<br></span></div><div><span style="font-family:courier new,monospace"> | <br>
</span></div><div><span style="font-family:courier new,monospace"> obj</span><br></div><div><br><br></div><div>Is that correct? In the 2nd case, is there any "reference counter" for TObject which counts how many "pointers" are pointing to the structure?<br>
</div><div><br></div><div>Thanks.<br></div><div><br></div></div></div>