[fpc-pascal] how to convert this to mode objfpc

Sven Barth pascaldragon at googlemail.com
Mon May 11 17:23:12 CEST 2015


Am 11.05.2015 16:49 schrieb "misu kun" <misu.dev at gmail.com>:
>
> thanks
> in objfpc mode i can imagine this ,but it didn't work unless i specialize
(obj)
>
>
> type
>      generic obj<T> = object
>                 x : T;
>      end;
> operator + (arg1 ,arg2 : obj):obj; // error : here (obj) needs
specialization
> 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.

Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20150511/5a2a2eb1/attachment.html>


More information about the fpc-pascal mailing list