2014-10-02 102 views
1

似乎一切都在我的代码中检查;我已经检查了不同函数的语法,并且所有内容似乎都在检查中,但我似乎仍然在XCode中收到错误'No Matching Function for Call to'MyInput'',没有任何解释。任何帮助,将不胜感激!代码如下。没有匹配的函数调用 - 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

您试图调用该函数,这需要int&作为最后一个参数

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

,但你通过const int max到它,这有const int类型,不能转化为int&

要修复它,将int&更改为int用于方法声明和定义

+0

解决了它,谢谢你! – Codetographer 2014-10-02 17:02:02

+0

它为dladdr((const void *)func,&test)工作,其中“func”是一个带“std :: string”返回的函数。 – GLCraft 2017-07-12 14:02:32