内置数据类型和枚举的运算符重载
Operator overloading for built-in data types and enums
Delphi中的枚举是否可以重载隐式类型转换?
program TriState;
type
TTrilean = (trNone = -1, trFalse = 0, trTrue = 1);
TTrileanHelper = record helper for TTrilean
public
class operator Implicit(...)...; //E2123 PROCEDURE, FUNCTION, PROPERTY, or VAR expected
end;
var
v: TTrilean;
begin
v := trNone;
v := True; //Would like to have class operator Implicit here
end.
在 Delphi 10.4.2 documentation 我读到:
Note: Class and record helpers do not support operator overloading.
Delphi中的枚举是否可以重载隐式类型转换?
program TriState;
type
TTrilean = (trNone = -1, trFalse = 0, trTrue = 1);
TTrileanHelper = record helper for TTrilean
public
class operator Implicit(...)...; //E2123 PROCEDURE, FUNCTION, PROPERTY, or VAR expected
end;
var
v: TTrilean;
begin
v := trNone;
v := True; //Would like to have class operator Implicit here
end.
在 Delphi 10.4.2 documentation 我读到:
Note: Class and record helpers do not support operator overloading.