[fpc-pascal] enumerate generic trees

Xiangrong Fang xrfang at gmail.com
Thu Mar 21 17:00:20 CET 2013


Hi There,

I encountered a problem writing enumerator for my generic tree. The
enumerator class looks like this:

  TTreapEnumerator = class
    FStack: TStack;
    FCurrent: TTreap.PNode;
  public
    constructor Create(ANode: TTreap.PNode);
    destructor Destroy; override;
    function MoveNext: Boolean;
    property Current: TTreap.PNode read FCurrent;
  end;

And the error message I got is:

/home/xrfang/git/fpcollection/src/units/treap.pas(363,45) Error:
Incompatible type for arg no. 1: Got
"THistogram.TTreap$Char$LongInt.PNode", expected "TTreap.PNode"

i.e. the enumerator expected a generic PNode, but the given node is a
specialized one.  How to write enumerators for generic classes?

Thanks!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20130322/bd6643b7/attachment.html>


More information about the fpc-pascal mailing list