#include <iostream>
usingnamespace std;
int calcStayCharges(int days, 350)
{
return 350 * days;
}
int calcMiscCharges(int medical, int surgical, int labFees, int rehab)
{
return medical + surgical + labFees + rehab;
}
int calcTotalCharges(int calcStayCharges, int calcMiscCharges)
{
return calcStayCharges + calcMiscCharges;
}
int main()
{
int days;
cout << "Number of days spent in the hospital: " << endl;
cin >> days;
int medical;
cout << "Amount of medical charges: " << endl;
cin >> medical;
int surgical;
cout << "Amount of surgical charges: " << endl;
cin >> surgical;
int labFees;
cout << "Amount of lab fees: " << endl;
cin >> labFees;
int rehab;
cout << "Amount of physical rehabilitation charges: $" << endl;
cin >> rehab;
int total = calcTotalCharges(calcStayCharges, calcMiscCharges);
cout << "The total cost of hospital stay is: $" << total << endl;
return 0;
}
When I execute it, it gives me these 2 errors:
1) error C2059: syntax error : 'constant'
2) error C2664: 'calcTotalCharges' : cannot convert parameter 1 from 'int (__cdecl *)(int)' to 'int'
int calcStayCharges(int days)
{
return 350 * days;
}
You can't put a constant as an argument parameter.
Edit:
Now that i read the rest of your code. You also need to pass variables to those parameters.
1 2 3
//int total = calcTotalCharges(calcStayCharges, calcMiscCharges);
//replace with:
int total = calcTotalCharges(calcStayCharges(days), calcMiscCharges(medical, surgical, labFees, rehab));