Operator overloading

type
  TPoint = record
    X, Y: Integer;
    constructor Create(AXAYInteger);
    class operator Add(
      const L, R: TPoint): TPoint;
  end;

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

class operator TPoint.Add(
  const L, R: TPoint): TPoint;
begin
  Result := TPoint.Create(
    L.X + R.X, L.Y + R.Y);
end;

var
  P1P2P3TPoint;
begin
  P1 := TPoint.Create(11);
  P2 := TPoint.Create(22);

  P3 := P1 + P2;
  //p3 is (3, 3)
  WriteLn('x = 'P3.X', y = 'P3.Y);

  //no "+=": plain re-assignment
  P3 := P3 + TPoint.Create(35);
  //p3 is (6, 8)
  WriteLn('x = 'P3.X', y = 'P3.Y);
end.