[fpc-pascal] class inheritance and type incompatibility
Xiangrong Fang
xrfang at gmail.com
Thu Sep 26 16:42:32 CEST 2013
>
> What should work is the following (now with generics again):
>
> === code begin ===
>
> type
> TTree<T> = class
> private type
> TSelfClass = class of TTree;
> public
> function Clone: TTree;
> end;
>
> function TTree.Clone: TTree;
> begin
> Result := TSelfClass(Self.ClassType).**Create(Data, FParent);
> (* ... *)
> end;
>
> After change to this code in Clone(), I got this error:
tree.pas(66,60) Error: Incompatible type for arg no. 2: Got
"TIntTree.TTree$LongInt", expected "TTree"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20130926/95270d83/attachment.html>
More information about the fpc-pascal
mailing list