type
TPoint = record
X, Y: Integer;
constructor Create(AX, AY: Integer);
class operator Add(
const L, R: TPoint): TPoint;
end;
constructor TPoint.Create(AX, AY: Integer);
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
P1, P2, P3: TPoint;
begin
P1 := TPoint.Create(1, 1);
P2 := TPoint.Create(2, 2);
P3 := P1 + P2;
//p3 is (3, 3)
WriteLn('x = ', P3.X, ', y = ', P3.Y);
//no "+=": plain re-assignment
P3 := P3 + TPoint.Create(3, 5);
//p3 is (6, 8)
WriteLn('x = ', P3.X, ', y = ', P3.Y);
end.