我在转换void (*)()
为float
. 这是我的代码:
#include <iostream>
using namespace std;
void instructions();
void numDays();
void med();
void sur();
void lab();
float room(int days);
float misc(float meds, float surgical, float lab);
float total(float room, float misc);
int main()
{
int days;
float meds;
float surgical;
instructions();
numDays();
med();
sur();
lab();
room( days);
misc(meds, surgical, lab);
total( room, misc);
}
void instructions()
{
cout<<"this program will ask you some questions. After that it will print out all of the users charges and the tital\
amount that is owed. "<<endl;
}
void numDays()
{
float days;
cout<<"Enter in users length of stay. "<<endl;
cin>> days;
}
void med()
{
float meds;
cout<<"Enter int the users medication charges. "<<endl;
cin>> meds;
}
void sur()
{
float surgical;
cout<<"Enter in the users surgical charges. "<<endl;
cin>> surgical;
}
void lab()
{
float lab;
cout<<"Enter in the users lab fees. "<<endl;
cin>> lab;
}
float room(float days)
{
float room;
room = (days*450);
}
float misc(float meds, float surgical, float lab)
{
float misc;
misc = (meds + surgical + lab);
return 0;
}
float total(float room, float misc)
{
float total;
total = (room + misc);
return total;
}
这些是我不断收到的错误消息:
:24: error: cannot convert 'void (*)()' to 'float' for argument `3' to `float misc(float, float, float)'
:25: error: cannot convert 'float (*)(int)' to 'float' for argument `1' to `float total(float, float)'