类模板的问题,调试出错
#include<iostream>using namespace std;
template <class numtype>
class compare
{
public:
compare(numtype a,numtype b)
{x=a;y=b;}
numtype max()
{return(x>y)?x:y;}
numtype min()
{return(x<y)?x:y;}
private :
numtype x,y;
};
int main()
{compare <int> cmp1(3,8);
cout<<cmp1.max()<<"is the max"<<endl;
compare <float> cmp2(14.5,16.8);
cout<<cmp2.max()<<"is the max"<<endl;
compare <char> cmp3('a','b');
cout<<cmp3.max()<<"is the max"<<endl;
return 0;
}
哪位兄弟帮忙看下,在运行的时候有两个错误。谢谢了!