[Lazarus] operator overloading

xrfang xrfang at gmail.com
Sun Feb 24 08:31:49 CET 2013


Hi All,

How can I use operator overloading?  I know the syntax, but it simply does not compile...  My situation is:

1. I wrote a TTreap generic class, which is a binary tree.
2. TTreap defines a Compare() with involves < and > operation on its keys.
3. I try to specialize it with the following:

===================================================
interface

TPainterManager = class(specialize TTreap<TPainter, Integer>)
public
    class operator < (p1, p2: TPainter) b: Boolean; <-- method1
end;

operator < (p1, p2: TPainter) b: Boolean; <-- method2

implementation
..
===================================================

but neither method1 nor method2 compiles.

What is the correct way to write operator overload routines?

Thanks,
Shannon  I 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20130224/6abefd4a/attachment-0002.html>


More information about the Lazarus mailing list