C++ 错误 :: 调用 'function' 没有匹配函数
c++ errors :: no matching function for call to 'function'
我知道这有点补救,但我似乎无法理解我的问题。这可能与论点中的参数有关,但我不确定。
void Input (int **&x, int *&arr, int &size1,int &size2, int a, int b)
{
cout << "Please enter 2 non-negative integer values: "<< endl;
cout << "1. ";
cin >> size1;
int checkVal(int size1, int a);
cout << "2. ";
cin >> size2;
int checkVal(int size2, int b);
void putArr(int **&x,const int &size1,const int &size2);
arr[0] = size1;
arr[1] = size2;
}
int checkVal (int &size, int x)
{
do{
if (size < 0)
cout << size << " is not a non-negative integer. Re-enter --> " << x << ". ";
cin >> size;
}while(size < 0);
return size;
}
void summation(int ***&y, int *&arr)
{
int *size = new int;
*size = **y[0] + **y[1];
y[2] = new int *(size);
*(arr + 2) = *size;
delete size;
}
int main()
{
int size, size1, size2;
int a = 1, b = 2;
int** x;
int*** y;
int** q;
int**** z;
int *arr[2];
allocArr(x, y, q, z);
Input(x, arr, size1, size2, a, b);
checkVal(size);
putArr(x, size1, size2);
summation(y, arr);
display(z);
}
这三种功能都会出现问题。我很困惑。提前谢谢。
不提那些目的不明的恒星,你在几个地方都有这样的代码:
cin >> size1;
int checkVal(int size1, int a);
cout << "2. ";
这里声明函数checkVal
,而不是调用它。在这种特殊情况下,我认为它应该被替换为
cin >> size1;
cout << "2. " << checkVal(size1, a);
(如果您提供正确类型的参数)
Input(x, arr, size1, size2, a, b);
// ...
summation(y, arr);
这两种情况下的问题都是第二个论点arr
。它的类型为int*[]
(指向int的指针数组),可以衰减为int**
(指向int指针的指针)类型,但此类型与参数类型int*&
(指向int指向指针的引用)不兼容。
checkVal(size);
这会失败,因为函数接受两个参数,但只传递一个,其余参数没有默认值。
这段代码中还有许多其他问题,但这解决了您的问题,即为什么这些函数的调用无法编译。
相关文章:
- "error: no matching function for call to"构造函数错误
- 库函数需要一个 std::function<void(void)>,如何传入类函数?
- 将函数包装器转换为 std::function
- 类型擦除的std::function与虚拟函数调用的开销
- 如何为 v8::P ersistent<v8::Function> 创建到 c++ 函数的包装器
- C++复制函数重载导致"must be a nonstatic member function"错误
- C++派生类重载函数(带有 std::function 参数)不可见
- 如何将函数指针从 std::function 传递到 Linux 克隆?
- 如何在跳过所有内部实现的同时跳转到 GDB 中 std::function 中的函数?
- 将函数的参数 - 签名从使用 'std::function<T>' 转换为模板参数类型
- C++:从重载函数转换为 std::function
- 仅当一个参数中未使用 std::function 时,模板函数替换才有效
- 使用 object 中的方法调用带有 std::bind 和 std::function.target 的 C 样式函数
- 插件:TypeError:addons.function() 不是一个函数
- 可变参数函数模板不能很好地使用 std::function 作为参数
- 将另一个类的成员函数传递到 std::function 参数中
- 如何从类成员函数返回指针,例如 size_t * class :: function(); 并使用类析构函数 ~size
- 创建函数变体向量时"No matching function for call"错误
- 在windows上使用ctypes在python中包装c++函数:function未找到
- 我所有的函数都有错误 C2084:函数'function'已经有一个主体