2014-11-20 123 views
-4

以下是我的完整代碼。我試圖包括住院病人,如果案件是一(1)但一些突出顯示是錯誤的。有沒有無論如何要解決這個問題,如果不是可以請你告訴我另一種方式,只要做到這一點,因爲它包括住院,如果一(1)進入如何在超載功能中包含和超載功能

void selection(int &); 
void processor(int &); 
void inPatient(double &, double &, double &, double &); 

int main() 
{ 
    int selected, include; 
    double numberOfDays, dailyRate, chargesForHospital, hospitalMedicationCharge; 

    selection(selected); 
    validate(selected, selected); 
    processor(selected); 

    system("pause"); 
    return(0); 
} 

void selection(int & selectedOption) 
{ 
    cout << "\nEnter Selection: "; 
    cin >> selectedOption; 
} 

void processor(int & selectedOption) 
{ 
    switch(selectedOption) 
    { 
     case 1: 
      inPatient(umberOfDays, dailyRate, chargesForHospital, hospitalMedicationCharge); 
      break; 
     case 2: 
      cout << "out-Pat" << endl; 
      break; 
     default : 
      cout << "Nothing Selected" << endl; 
      break; 
    } 
} 

void inPatient(double & numberOfDays, double & dailyRate, double & chargesForHospital, double & hospitalMedicationCharge) 
{ 
    cout << "The number of days spent in the hospital: "; 
    cin >> numberOfDays; 
    cout << "The daily rate: "; 
    cin >> dailyRate; 
    cout << "Charges for hospital services (lab tests, etc.): "; 
    cin >> chargesForHospital; 
    cout << "Hospital medication charges: "; 
    cin >> hospitalMedicationCharge; 
} 
+1

什麼問題? – Caleb 2014-11-20 22:28:24

+0

什麼是正確的方式來包括名稱帕特里克 – 2014-11-20 22:31:03

+3

這裏有太多的錯誤,發佈一些實際編譯的代碼。 – Aesthete 2014-11-20 22:31:41

回答

0

有您發佈一些代碼中的錯誤的,但我會盡力解決您的緊急問題。你試圖調用這樣的函數:

patric(int & gender, int & age) 

但這更像是一個函數聲明。實際調用的函數,你傳遞參數,但省略了類型,就像這樣:

patric(someGender, someAge); 

在聲明中int &說,參數是int類型的值引用,所以你傳遞的價值觀,當你調用patric應該是int

另外,你說patric已超載。這意味着該函數有幾個版本,每個版本都有不同的參數列表。因此,也許有一個上面還有一個不帶任何價值 - 也許他們的聲明分別是這樣的,:

void patric(int &gender, int &age); 
void patric(void); 

鑑於這種情況,如果你想叫的第二個版本,你」 (函數名前意味着它不會返回任何在第二個版本的參數列表中void意味着函數不帶任何參數void。)

patric(); 

:D叫它

還要注意你在函數調用之後需要一個分號(;)。

+0

你可以再看一遍嗎? – 2014-11-20 22:58:51