2014-10-02 100 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