[Lazarus] operator overloading

Vincent Snijders vincent.snijders at gmail.com
Fri Oct 22 16:38:38 CEST 2010


2010/10/22 Birger Jansen <birger at cnoc.nl>:
> Hi,
>
> In Delphi you can overload the Explicit operator. This makes is possible to have a type TTypeX and TTypeY and cast one into the other. To do that, implement an operator overloader:
>  operator Explicit(const AValue: TTypeX): TTypeY.
>  // implement converstio from TTypeX to TTypeY.
>
> Then you can do stuff like
> var
>  tx: TTypeX;
>  ty: TTypeY;
> begin
>  tx := TTypeX.Create;
>  ty := TTypeY(tx);
> end;
>
> Is something like this possible in FPC?

I don't know. If you don't get an answer, it may be useful to ask on
the fpc-pascal mailing list, that is a better place for such
questions:
http://lists.freepascal.org/mailman/listinfo/fpc-pascal/

Vincent




More information about the Lazarus mailing list