void ConvertFToC(double f, double &c);
void ConvertFToC(float f, float &c);
void ConvertFToC(int f, int &c);
int main()
{
double df, dc;
float ff, fc;
int i_f,i_c; //if is a reserved word
df = 75.0;
ff = 75.0;
i_f = 75;
cout << "Calling ""double"" version" << endl;
ConvertFToC(df,dc);
cout << df << " == " << dc << endl << endl;
cout << "Calling ""float"" version" << endl;
ConvertFToC(ff,fc);
cout << ff << " == " << fc << endl << endl;
cout << "Calling ""int"" version" << endl;
ConvertFToC(i_f,i_c);
cout << i_f << " == " << i_c << endl << endl;
}
void ConvertFToC(double f, double &c)
{
cout << "In ""double"" version" << endl;
c = (f - 32.0) * 5. / 9.;
}
void ConvertFToC(float f, float &c)
{
cout << "In ""float"" version" << endl;
c = (f - 32.0) * 5. / 9.;
}
void ConvertFToC(int f, int &c)
{
cout << "In ""int"" version" << endl;
c = (f - 32) * 5. / 9.;
}
0 comments:
Post a Comment