<div dir="ltr"><div><div><div><div><div>Hi All,<br><br>I wrote a TTree generic class, the code is here:<br><br><a href="https://github.com/xrfang/fpcollection/blob/master/src/units/tree.pas">https://github.com/xrfang/fpcollection/blob/master/src/units/tree.pas</a><br>

<br></div>While using this class, I encountered the following problem:<br><br><span style="font-family:courier new,monospace">program project1;<br>{$mode objfpc}{$H+}<br>uses tree;<br>type<br>  TIntTree = class(specialize TTree<Integer>)<br>

  end;<br>var<br>  ti : TIntTree;<br>begin<br>  ti := TIntTree.Create(1, nil);<br>  ti := ti.Next;  <-- error here<br>end.</span><br><br></div>The error message is:<br><br><span style="font-family:courier new,monospace">Error: Incompatible types: got "TIntTree.TTree$LongInt" expected "TIntTree"</span><br>

<br></div>If I do not inherit TTree but just specialize it, there is no error.<br><br></div>How can I solve this problem so that I don' t have to use typecast everywhere?<br><br>Thanks,<br></div>Xiangrong<br><div><div>

<div><div><br><div><br><br><br></div></div></div></div></div></div>