【问题标题】:c++/error: no matching function for call toc++/error: 没有匹配的调用函数
【发布时间】:2014-09-08 19:57:37
【问题描述】:

我知道它相当基本,但是我不太确定我的函数参数似乎有什么问题,但我不断收到错误消息:“没有匹配的函数用于调用‘输入’和‘求和’”。

void Input (int **&x, int *&arr, int &size1,int &size2)
{
    cout << "Please enter 2 non-negative integer values: "<< endl;
    cout << "1. ";
    cin >> size1;
    int checkVal(int size1);
    cout << "2. ";
    cin >> size2;
    int checkVal(int size2);

    void putArr(int **&x,const int &s1,const int &s2);

    arr[0] = size1;
    arr[1] = size2;

}

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

    int** x;
    int*** y;
    int** q;
    int**** z;

    int *arr[2];

    allocArr(x, y, q, z);

    checkVal(size);

    Input(x, arr, size1, size2);

    putArr(x, size1, size2);


    summation(y, arr);

    display(z);


}

提前谢谢你。

【问题讨论】:

  • 函数使用前需要先声明。
  • 正如@juanchopanza 所说,您需要声明这些函数。要么在文件顶部前向声明它们,要么更好的是,将它们放在单独的头文件中。
  • 那是很多*

标签: c++ function compiler-errors


【解决方案1】:

两个函数都有一个int *&amp;arr 参数,而您传入​​的是arr,即int *[2],因此参数不匹配。您需要传入arr[0]arr[1],具体取决于您要执行的操作。

【讨论】:

  • 宝贵的一课:如果你使用那么多级别的指针,你犯错误。
猜你喜欢
  • 2017-01-23
  • 2021-09-21
  • 2016-11-23
  • 2012-05-27
  • 1970-01-01
  • 1970-01-01
  • 2017-05-08
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多