overloading unary operators

Top  Previous  Next

New features since Delphi 7 > Operator Overloading > unary operators

 

Example of a negative operator:

 

 

class operator TMyClass.Negative(a: TMyClass): TMyClass;

var

  b : TMyClass;

begin

  b:= -a.payload;  

  Result:= b;

end;

 

 

Delphi2C# converts this to:

 

 

public static TMyClass operator - (TMyClass a)

{

  TOperatorClass result = TMyClass.CreateRecord();

  TOperatorClass b = TMyClass.CreateRecord();

  b = -a.payload;  // Use the implicit conv here?

  result = b;

  return result;

}

 

 

 

 

 

 

 

 

 

 

 

 

 

 



This page belongs to the Delphi2C# Documentation

Delphi2C# home  Content