The implicit and explicit conversion operators for records permit overloading by return type: namely, the type being converted to:
type
TFoo = record
class operator Implicit(const AFoo: TFoo): Integer;
class operator Implicit(const AFoo: TFoo): string;
end;
Depending on the context, using a value of type TFoo
will call the appropriate implicit conversion. If trying to use a value of type TFoo
as an argument to an overloaded routine that can take either Integer or string in that position, an overload error will occur:
test.pas(33) Error: E2251 Ambiguous overloaded call to 'Q'
+ Test.pas(19) Related method: procedure Q(Integer);
+ Test.pas(24) Related method: procedure Q(const string);