我收到以下代码的“预期常量表达式”错误:
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;
我在标记的行上收到错误:
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;
有人知道发生了什么吗?
提前致谢!