You can't extend it but you can make a transfer type like this:
[pascal]type
TMyPoint = record
fpoint: TPoint;
class operator add(a, b: TMyPoint): TMyPoint;
class operator implicit(a: TMyPoint): TPoint;
class operator implicit(a: TPoint): TMyPoint;
END;
class operator TMyPoint.add(a, b: TMyPoint): TMyPoint;
begin
result.fpoint.x := a.fpoint.x+b.fpoint.x;
result.fpoint.y := a.fpoint.y+b.fpoint.y;
end;
class operator implicit(a: TMyPoint): TPoint;
begin
result =: a.fpoint;
end;
class operator implicit(a: TPoint): TMyPoint;
begin
result.fpoint := a;
end;[/pascal]
Now you can use it like this:
[pascal]
var a,b: tmypoint;
c: tpoint;
begin
a := point(2,5);
b := point(5,7);
a := a+b;
c := a;
end;
[/pascal]
Since you are danish I can point you toward my article on OO in delphi http://udvikleren.dk/Delphi/Article.aspx/297/
Bookmarks