gpt4 book ai didi

C++错误::没有匹配函数来调用 'function'

转载 作者:行者123 更新时间:2023-11-28 02:41:44 25 4
gpt4 key购买 nike

我知道这有点补救措施,但我似乎无法理解我的问题。它可能与参数中的参数有关,但我不确定。

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);

(前提是您提供正确类型的参数)

关于C++错误::没有匹配函数来调用 'function',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25734404/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com