[fpc-devel] class operator overloads
Ryan Joseph
genericptr at gmail.com
Mon Jun 10 20:35:30 CEST 2019
> On Jun 10, 2019, at 2:21 PM, Sven Barth via fpc-devel <fpc-devel at lists.freepascal.org> wrote:
>
> There exist only two assignment operators, namely "Implicit" (aka := in mode ObjFPC) and "Explicit" both taking a single argument. Introducing a binary operator does not change that the operator is forbidden for classes.
>
>
> I just tried this right now and I didn’t an error but it was indeed not overloaded and never got called. A bug?
>
> operator := (left, right: TObject): TObject;
> begin
> writeln('custom :=');
> end;
>
> var
> c: TObject;
> begin
> c := TObject.Create;
> end.
>
> Did you try with trunk? Cause I fixed something related to that a few weeks ago.
>
Yeah in trunk it says impossible overload for equal types.
Regards,
Ryan Joseph
More information about the fpc-devel
mailing list