Hallo,
Der Constructor bei Records ist eher eine Init-Methode, in der man Felder initialisieren kann.
Delphi-Quellcode:
type
TPointEx = record
X,Y: Integer;
constructor Create(AX,AY: Integer);
end;
constructor TPointEx.Create(AX,AY: Integer);
begin
X := AX;
Y:= AY;
end;
procedure TForm1.FormCreate(Sender: TObject);
var Pt: TPointEx;
begin
Pt.X := 123;
Pt.Y := 987;
Caption := Format('X: %d, Y: %d',[Pt.X,Pt.Y]);
Pt := TPointEx.Create(10,20);
Caption := Caption + ' ' + Format('X: %d, Y: %d',[Pt.X,Pt.Y]);
end;
Beide Methoden funktionieren ohne Probleme.
Pt := TPointEx.Create(10,20);
ist quasi eine Alternative zu
Pt := Point(10,20);
Michael
"Programmers talk about software development on weekends, vacations, and over meals not because they lack imagination,
but because their imagination reveals worlds that others cannot see."