Operator overloading

type
  TPoint = record
    X, Y: Integer;
    constructor Create(AXAYInteger);
    class operator Negative(
      const P: TPoint): TPoint;
    class operator Inc(
      const P: TPoint): TPoint;
  end;

constructor TPoint.Create(AXAYInteger);
begin
  X := AX;
  Y := AY;
end;

class operator TPoint.Negative(
  const P: TPoint): TPoint;
begin
  Result := TPoint.Create(-P.X, -P.Y);
end;

class operator TPoint.Inc(
  const P: TPoint): TPoint;
begin
  Result := TPoint.Create(P.X + 1, P.Y + 1);
end;

var
  P: TPoint;
begin
  //operators overload only on records
  P := TPoint.Create(11);

  Inc(P);
  //p is (2, 2)
  WriteLn('x = ', P.X', y = ', P.Y);

  P := -P;
  //p is (-2, -2)
  WriteLn('x = ', P.X', y = ', P.Y);
end.