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