c++ - "error: invalid conversion from ' int' 到 'int (*)[8]' [-fpermissive] 的含义是什么?

标签 c++ compiler-errors

#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/

相关文章:

c++ - 从隐藏变为可见时,如何阻止窗口短暂地重新出现在其最后可见的位置?

c++ - C++ 中的私有(private)成员与临时变量

c++ - 我的 x86 目标文件中这些看似无用的 callq 指令有什么用?

html - 在 img 源属性 (Umbraco) 中插入媒体 url 时出现 CS1502 错误

git - 移动git项目导致许多Blob和树错误

c++ - 在协程句柄上调用 destroy 会导致段错误

c++ - 适用于足球经理等数据驱动游戏的语言和数据库

java - Jsp无法将类解析为特定类的类型?

cmake - 带有 CMake 的 STM32 项目

compiler-errors - SwiftUI初始值设定项的圆形度