Registriert seit: 26. Mai 2004
3.159 Beiträge
|
AW: How convert c++ code ?
11. Dez 2010, 15:45
Yes, there is a way. You can use the TList (or TObjectList) instead of the c++ vector type.
Delphi-Quellcode:
type
TVector2 = class
private
FX : Extended;
FY : Extended;
public
constructor Create(AX, AY: Extended);
property X : Extended read FX write FX;
property Y : Extended read FY write FY;
end;
var
vList : TList;
vMin, vMax : TVector2;
x, y : Extended;
begin
vList := TList.Create();
vMin := TVector2.Create(1.2, 1.2);
vMax := TVector2.Create(8.9, 8.9);
try
y := vMin.y;
while (y < vMax.y) do
begin
x := vMin.x;
while (x < vMax.x) do
begin
vList.Add(TVector2.Create(x, y));
x := x + 1.0;
end;
y := y + 1.0;
end;
finally
vMin.Free();
vMax.Free();
end;
// vList contains all created vectors now...
end;
»Remember, the future maintainer is the person you should be writing code for, not the compiler.« (Nick Hodges)
|