没有匹配函数来调用 - Xcode?

时间:2014-10-02 04:08:52

标签: c++ xcode

一切似乎都在我的代码中查看;我检查了不同功能的语法,一切似乎都在检查,但我似乎仍然收到错误'没有匹配功能来调用“我的输入”''在XCode中没有解释。任何帮助,将不胜感激!代码如下。

#include <iostream>
#include <iomanip> 
using namespace std;

typedef char ShortName[10];
typedef char LongName[17];
typedef char IDarray[6];

void MyInput(ShortName [],char [], LongName [], float [],int [],IDarray [],int&);



int main(int argc, const char * argv[])
{
    const int max = 7;
    const int ConstStateTax = .05;
    const int ConstFedTax = .15;
    const int ConstUnionFees = .02;
    ShortName firstname[max];
    char MI[max];
    LongName lastname[max];
    float hourrate[max];
    int OTHours[max];
    float Gross[max];
    float Overtime[max];
    float GGross[max];
    float StateTax[max];
    float FedTax[max];
    float UnionFees[max];
    IDarray EmployeeID[max];
    float Net[max];

    MyInput(firstname,MI,lastname,hourrate,OTHours,EmployeeID,max);


    return 0;
}

void MyInput(ShortName firstname[],char MI[],LongName lastname[],float hourrate[],int OTHours[],IDarray EmployeeID[],int &max)
{
    for(int i = 0;i<=max;i++)
    {
        cout << "Please enter the first name of employee #" << i+1 << ": ";
        cin >> firstname[i];
        cout << "Please enter the middle initial of employee #" << i+1 << ": ";
        cin >> MI[i];
        cout << "Please enter the last name of Employee #" << i+1 << ": ";
        cin >> lastname[i];
        cout << "What is the ID number of Employee #" << i+1 << "? (6 letters or numbers only): ";
        cin >> EmployeeID[i];
        cout << "What is the hourly rate of employee #" << i+1 << "? ";
        cin >> hourrate[i];
        while (hourrate[i] < 0)
        {
            cout << "Invalid rate, please try again: ";
            cin >> hourrate[i];
        }
        cout << "How many overtime hours does employee #" << i+1 << " have? ";
        cin >> OTHours[i];
        while(OTHours[i]<0 || OTHours[i] >20)
        {
            cout << "Invalid Overtime Hours, please re-enter: ";
            cin >> OTHours[i];
        }
    }


}

1 个答案:

答案 0 :(得分:2)

您要调用的函数是,int&作为最后一个参数

void MyInput(ShortName [],char [], LongName [], float [],int [],IDarray [],int&);

但您将const int max传递给它,其类型为const int且无法转换为int&

要解决此问题,请将int&更改为int以获取方法声明和定义