Codetographer
Codetographer

Reputation: 41

no matching function for call to - Xcode?

Everything seems to check out in my code; I've checked syntax on the different functions and everything seems to be checking out but I still seem to be getting the error 'No Matching Function for Call to 'MyInput'' in XCode with no explanation. Any help would be appreciated! Code follows.

#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];
        }
    }


}

Upvotes: 2

Views: 10284

Answers (1)

Bryan Chen
Bryan Chen

Reputation: 46578

the function you are trying to call is, which takes int& as last argument

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

but you pass const int max to it, which have type of const int and can't convert to int&

to fix it, change int& to int for both method declaration and definition

Upvotes: 2

Related Questions