所以我不知道为什么我会收到这个错误说"错误:类型的争论"颜色"与#34; color(*)[2]""类型的参数不兼容在我标记的行
#include <iostream>
using namespace std;
enum color{black, white};
bool negative(color a[2][2], color b[2][2]);
void main(){
color a[2][2] = { { black, white }, { white, black } };
color b[2][2] = { { white, black }, { black, white } };
negative(a[2][2], b[2][2]); //<==== here (under "a" and "b")
}
bool negative(color a[2][2], color b[2][2]){
int False=0, True=0;
for (int i = 0; i < 2; i++){
for (int j = 0; j < 2; j++){
if (a[i][j] != b[i][j]) True++;
else False++;
}
}
if (True == 2 && False == 0)return true;
else if (True == 0 && False == 2)return false;
}
答案 0 :(得分:0)
negative
函数接受color
个参数数组的数组,但是你传递一个单个 color
值,一个超出范围的值数组也是如此。
呼叫
negative(a, b);
我建议你回到你的书或教程,阅读有关数组的更多信息。
答案 1 :(得分:0)
你的问题是你应该传递一个数组,而是你试图传递一个元素(它甚至不存在)。
当你这样做时
a[2][2]
你描述了第三行,第三列(如果你认为你的2d数组为表)元素。
negative(a,b)
是你可能想要做的。