小编Ale*_*x O的帖子

Delphi数组初始化

我目前有这个,它很糟糕:

type TpointArray = array [0..3] of Tpoint;

class function rotationTable.offsets(pType, rotState, dir: integer): TpointArray;
begin

  Result[0] := point(1, 1);
  Result[1] := point(1, 2);
  Result[2] := point(1, 1);
  Result[3] := point(1, 1);
end;
Run Code Online (Sandbox Code Playgroud)

但相反,我想做这样的事情:

class function rotationTable.offsets(pType, rotState, dir: integer): TpointArray;
begin
   Result := [Point(1,1), Point(1,2), Point(1,1), Point(1,1)];
end;
Run Code Online (Sandbox Code Playgroud)

但是,在编译时,它抱怨[1,2,3,4]语法只适用于整数.

有没有办法实例化/初始化一个Tpoint数组,类似于我想要的方式?

arrays delphi point tobject

18
推荐指数
3
解决办法
3万
查看次数

标签 统计

arrays ×1

delphi ×1

point ×1

tobject ×1