<p>Am 30.09.2013 04:10 schrieb "Xiangrong Fang" <<a href="mailto:xrfang@gmail.com">xrfang@gmail.com</a>>:<br>
><br>
> 2013/9/30 Sven Barth <<a href="mailto:pascaldragon@googlemail.com">pascaldragon@googlemail.com</a>><br>
>><br>
>><br>
>>> However, this does not work, because it seems that I cannot make any<br>
>>> generic method virtual! In TIntTree, I have to write:<br>
>>><br>
>>> function TIntTree.DoClone: TIntTree;<br>
>>><br>
>>> As it is not possible to write TTree outside of the generic definition.<br>
>><br>
>><br>
>> This should do it:<br>
><br>
> <br>
> Right, this worked. My last question for this issue: is the TSelfType a 2.6.2 workaround, or it is required even in 2.7.1? I mean, how about this:<br>
><br>
> === code ===<br>
> type<br>
> generic TTree = class<br>
> protected<br>
> procedure DoClone(aNode: TTree); virtual; //<<-- instead of TSelfType<br>
> end;<br>
> TIntTree = class(specialize TTree<Integer)<br>
> protected<br>
> procedure DoClone(aNode: TTree); override; //<<-- instead of TSelfType<br>
> end;<br>
> === end code ===<br>
><br>
> In another word, use "TTree" to represent any of its specialization and their descendants. Is it possible in 2.7.1 or later?</p>
<p>You don't require "TSelfType" in 2.7.1, but the correct one is not "TTree", but "specialize TTree<Integer>". If "TTree" should work then that's a bug...</p>
<p>Regards,<br>
Sven</p>