哪里错了呢?
题目:利用重载函数实现求3个数最大值的程序,要求能够分别求出整型、浮点型、双精度型以及字符型。#include<iostream>
using namespace std;
int max,x,y,z;
cout<<enter three numbers:<<endl;
cin>>x>>endl;
cin>>y>>endl;
cin>>z>>endl;
compare(int a,int b,int c)
{
max=a>b?a:b;
max=max>c?max:c;
}
compare(float a,float b,float c)
{
max=a>b?a:b;
max=max>c?max:c;
}
compare(double a,double b,double c)
{
max=a>b?a:b;
max=max>c?max:c;
}
compare(char a,char b,char c)
{
max=a>b?a:b;
max=max>c?max:c;
}
int main()
{
cout<<compare(int x,int y,int z)<<max<<endl;
cout<<compare(float x,float y,float z)<<max<<endl;
cout<<compare(double x,double y,double z)<<max<<endl;
cout<<compare(char x,char y,char z)<<max<<endl;
return 0;
}