[Lazarus] operator overloading

xrfang xrfang at gmail.com
Mon Feb 25 04:03:04 CET 2013


I confirm that it does not work.  Test program below, and the class source is attached.


==Test Program===================

program test;

{$mode objfpc}{$H+}

uses
  Classes, treap;

type
  TSLCounter = specialize TTreap<TStringList, Integer>;

operator <(sl1, sl2: TStringList): Boolean;
begin
  Result := sl1.Text < sl2.Text;
end;

begin
end.

==Error Message==================
Options changed, recompiling clean with -B
/home/xrfang/git/fpcollection/src/units/treap.pas(216,10) Error: Operator is not overloaded: "TStringList" < "TStringList"
/home/xrfang/git/fpcollection/src/units/treap.pas(218,15) Error: Operator is not overloaded: "TStringList" > "TStringList"
test.lpr(19) Fatal: There were 2 errors compiling module, stopping
=================================

i.e. whether the operator overloading is defined or not, error message is same.

Thanks.

在 日, 2月 24, 2013 at 4:21 下午,leledumbo <leledumbo_cool at yahoo.co.id> 写道:
FPC operator overloading doesn't work inside classes, it must be declared 
globally, so method2 should work. What error do you get? What FPC version do 
you use? 



-- 
View this message in context: http://free-pascal-lazarus.989080.n3.nabble.com/Lazarus-operator-overloading-tp4029399p4029400.html 
Sent from the Free Pascal - Lazarus mailing list archive at Nabble.com. 

-- 
_______________________________________________ 
Lazarus mailing list 
Lazarus at lists.lazarus.freepascal.org 
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20130225/6e648584/attachment-0003.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: treap.pas
Type: text/x-pascal
Size: 5759 bytes
Desc: not available
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20130225/6e648584/attachment-0001.pas>


More information about the Lazarus mailing list