小编Ric*_*oss的帖子

德尔福常量表达式预期

我使用以下代码获得"预期的常量表达式"错误:

TBoard 定义为:

  TBoard = class
    field: array[1..5,1..5] of Integer;

    function check(const x, y: Integer): Integer;
    function addShip(x, y, size, dir: Integer): Integer;
    function attack(const x, y: Integer): Integer;
  end;
Run Code Online (Sandbox Code Playgroud)

我在标记的行上得到错误:

function TBoard.attack(const x, y: Integer): Integer;
begin
  Result := Self.check(x, y);
  case Result of
  0:
    Self.field[x, y] := 1;
    Exit; // error: constant expression expected
  else Exit;
  end;
end;
Run Code Online (Sandbox Code Playgroud)

有人知道发生了什么吗?
提前致谢!

delphi constant-expression

1
推荐指数
1
解决办法
2747
查看次数

标签 统计

constant-expression ×1

delphi ×1