小编use*_*730的帖子

C++ 编译错误:数组具有不完整的元素类型“int []”

我正在用 C++ 编写康威的生命游戏。我收到一个编译时错误,这与我将二维数组传递给方法的方式有关:

gameoflife.cpp:5:25: error: array has incomplete element type 'int []'
void print_game(int game[][], int SIZE);

gameoflife.cpp:6:23: error: array has incomplete element type 'int []'
void run_game(int game[][], int SIZE);

gameoflife.cpp:7:23: error: array has incomplete element type 'int []'
void set_cell(int game[][], int i, int j, int next[][], int SIZE);
Run Code Online (Sandbox Code Playgroud)

等等。

我的代码的开头是:

void print_game(int game[][], int SIZE);
void run_game(int game[][], int SIZE);
void set_cell(int game[][], int i, int j, int next[][], int SIZE);
Run Code Online (Sandbox Code Playgroud)

显然问题从这里开始。

在方法中传递二维数组有什么问题?我应该改用 ** 吗?

c++ methods multidimensional-array

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

标签 统计

c++ ×1

methods ×1

multidimensional-array ×1