Расширения

uses System.Math;

type
  TPoint = class
  public
    X, Y: Double;
    constructor Create(AXAYDouble);
  end;

  //class helper extends the class
  //without touching its source
  TPointHelper = class helper for TPoint
    function DistanceTo(P: TPoint): Double;
  end;

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

function TPointHelper.DistanceTo(
  P: TPoint): Double;
begin
  Result := Sqrt(Power(X - P.X2) +
    Power(Y - P.Y2));
end;

var
  P1P2TPoint;
begin
  P1 := TPoint.Create(12);
  P2 := TPoint.Create(23);

  WriteLn('distance is ',
    P1.DistanceTo(P2):0:4);
  //distance is 1.4142
end.