"Sven Barth" wrote 5 lines
Am 11.05.2015 16:49 schrieb "misu kun" :
>
> thanks
> in objfpc mode i can imagine this ,but it didn't work unless i
specialize (obj)
Show quoted text 7 lines
>
>
> type
> generic obj<T> = object
> x : T;
> end;
> operator + (arg1 ,arg2 : obj):obj; // error : here (obj) needs
specialization
Show quoted text 5 lines
> begin
> result.x := arg1.x + arg2.x;
> end;
The method needs to be part of the object (you should use "record"
though) like in the mode-Delphi-code, for this you need to add {$modeswitch advancedrecords} after the {$mode objfpc} directive.
And just to be clear: it needs to be "class operator +" inside of "obj".
Regards,
Sven