我正在用 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)
显然问题从这里开始。
在方法中传递二维数组有什么问题?我应该改用 ** 吗?