Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2014-08

Operator overloading and generic class

2 messages · 1 person ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Xiangrong Fang

Hi All,

While I try to compile this code:

program demo;
{$mode objfpc}{$H+}
uses tree;
type
  TIntTree = class(specialize TTree<Integer>)
  end;
  TITTree = class(specialize TTree<TIntTree>)
  end;
operator <(it1, it2: TIntTree): Boolean;
begin
  Result := it1.Data < it2.Data;
end;
var
  itt: TITTree;
begin
end.

I got the following error:

tree.pas(324,11) Error: Operator is not overloaded: "TIntTree" < "TIntTree"

The complete code for tree.pas is here:

https://github.com/xrfang/fpcollection/blob/master/src/units/tree.pas

Even I defined the needed operator like above, it still refuse to compile.

How to solve this?

Thanks in advance!

Xiangrong

Reply by email

Xiangrong Fang
to Xiangrong Fang

Sorry, I asked similar question long time ago, I found it in my gmail.

Please ignore this question. However, I hope FPC will add this feature in future release anyway.

2014-08-26 16:17 GMT+08:00 Xiangrong Fang :

Show quoted text 43 lines
Hi All, While I try to compile this code: program demo; {$mode objfpc}{$H+} uses tree; type TIntTree = class(specialize TTree<Integer>) end; TITTree = class(specialize TTree<TIntTree>) end; operator <(it1, it2: TIntTree): Boolean; begin Result := it1.Data < it2.Data; end; var itt: TITTree; begin end. I got the following error: tree.pas(324,11) Error: Operator is not overloaded: "TIntTree" < "TIntTree" The complete code for tree.pas is here: https://github.com/xrfang/fpcollection/blob/master/src/units/tree.pas Even I defined the needed operator like above, it still refuse to compile. How to solve this? Thanks in advance! Xiangrong

Reply by email