overloading binary operators |
Top Previous Next |
New features since Delphi 7 > Operator Overloading > binary operators
The translation of overloaded binary operators is straightforward. This is shown in the following example:
class operator TMyClass.Add(a, b: TMyClass): TMyClass; var returnrec : TMyrClass; begin returnrec.payload := a.payload + b.payload; Result:= returnrec; end;
becomes in C++ to:
TMyClass operator + (const TMyClass& A, const TMyClass& B) { TMyClass result = {0}; TMyClass returnrec = {0}; returnrec.payload = A.payload + B.payload; result = returnrec; return result; }
Problematic are the operator IntDivide and LogicalXor because they don't have counterparts in C++. Delphi2Cpp converts IntDivide to a normal Divide operator /. As long as there isn't an additional Divide operator this will work. There is no automatic for LogicalXor yet.
|
This page belongs to the Delphi2Cpp Documentation |
Delphi2Cpp home Content |