[fpc-pascal] Incompatible type for generics?
Xiangrong Fang
xrfang at gmail.com
Mon Sep 23 09:09:45 CEST 2013
Hi All,
I wrote a TTree generic class, the code is here:
https://github.com/xrfang/fpcollection/blob/master/src/units/tree.pas
While using this class, I encountered the following problem:
program project1;
{$mode objfpc}{$H+}
uses tree;
type
TIntTree = class(specialize TTree<Integer>)
end;
var
ti : TIntTree;
begin
ti := TIntTree.Create(1, nil);
ti := ti.Next; <-- error here
end.
The error message is:
Error: Incompatible types: got "TIntTree.TTree$LongInt" expected "TIntTree"
If I do not inherit TTree but just specialize it, there is no error.
How can I solve this problem so that I don' t have to use typecast
everywhere?
Thanks,
Xiangrong
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20130923/e046bc67/attachment.html>
More information about the fpc-pascal
mailing list