What am I doing wrong?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <iostream>
using namespace 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'
Last edited on
Your error is in the top function.

do this instead;

1
2
3
4
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));
Last edited on
So how would I multiple the days by $350 if I can't put it where I have it?
if you look at the code I put in, the days get multiplied by 350 on the return line.
Oh! I over looked where you took it out of the first line. Thank you so much!
Topic archived. No new replies allowed.