overloading unary operators |
Top Previous Next |
New features since Delphi 7 > Operator Overloading > unary operators
While the operators Negative, Positive, LogicalNot, Inc and Dec have a parameter and a return value, in Delphi, the counterparts in C++ don't have a parameter, but return a modified copy of themselves. The code for the operator implementation has to be remodeled accordingly. This is demonstrated at the example of the Negative operator:
class operator TMyClass.Negative(a: TMyClass): TMyClass; var b : TMyClass; begin b:= -a.payload; Result:= b; end;
Delphi2Cpp II converts this to:
TOperatorClass TOperatorClass::operator - () const { TOperatorClass result = {0}; TOperatorClass B = {0}; B = -this->payload; // Use the implicit conv here? result = B; return result; }
All occurrences of the parameter are substituted by this in C++.
|
This page belongs to the DelphiXE2Cpp11 Documentation |
DelphiXE2Cpp11 home Content |