What kinds of operator overloads does Delphi support?

后端 未结 2 474
春和景丽
春和景丽 2020-12-31 04:48

I wonder what sort of operator overloads are possible (and with what version of Delphi)? Thanks to Hallvard\'s great write-up on operator overloading, I know of :

2条回答
  •  抹茶落季
    2020-12-31 05:27

    Actually, I found the answer to this myself, but kept the question as I can imagine people will search for this information regularly on stackoverflow;

    The official description on operator overloaders can be found here : http://docwiki.embarcadero.com/RADStudio/en/Operator_Overloading_(Delphi)

    Mainly, the ones I was looking for are named:

    • Equal, for '=' comparison : Equal(a: type; b: type) : Boolean;
    • NotEqual, for '<>' comparison : NotEqual(a: type; b: type): Boolean;
    • GreaterThan, for '>' comparison : GreaterThan(a: type; b: type) Boolean;
    • GreaterThanOrEqual, for '>=' comparison : GreaterThanOrEqual(a: type; b: type): resultType;
    • LessThan, for '<' comparison : LessThan(a: type; b: type): resultType;
    • LessThanOrEqual, for '<=' comparison : LessThanOrEqual(a: type; b: type): resultType;

提交回复
热议问题