#include <iostream>
using namespace std;
enum {ROW = 7, COLUMN = 8};
void show(int matrix[][COLUMN], int, int);
int main (){
int horizontal = 0;
int vertical = 5;
int goldCoin[ROW][COLUMN] = {
{5, 1, 0, 4, 1, 1, 2, 0},
{0, 3, 2, 1, 0, 3, 0, 1},
{4, 3, 0, 6, 5, 0, 1, 0},
{3, 1, 0, 3, 4, 0, 1, 3},
{0, 5, 2, 0, 1, 1, 5, 1},
{2, 1, 6, 1, 6, 0, 2, 1},
{0, 0, 4, 3, 2, 3, 0, 2}
};
show(goldCoin[ROW][COLUMN], 1, 1);
return 0;
}
void show(int matrix[][COLUMN], int x, int y){
if(y >= COLUMN)
cout << "[error: column index is beyond array limit]" << endl;
else
cout << "[" << matrix[x][y] << "]" << endl;
}
The error is pointing to the function call 'show(goldCoin[ROW][COLUMN], 1, 1);' inside main. As a beginner I don't see any syntactical errors on that statement. Can somebody help?
最佳答案
在调用 show(goldCoin[ROW][COLUMN], 1, 1);
时,您传递的是 int
作为第一个参数,而不是二维数组,因为您可能想要。
我相信您打算改为执行 show(goldCoin, 1, 1);
。
关于c++ - "error: invalid conversion from ' int' 到 'int (*)[8]' [-fpermissive] 的含义是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46810978/