类模板的问题
#include <iostream>using namespace std;
template <class T>
class compare
{
public:
compare(T x,T y):a(x),b(y){}
T max();
private:
T a;
T b;
};
T compare::max()
{
return (a>b)?a:b;
}
int main()
{
compare<int> c1(3,7);
cout<<c1.max()<<endl;
compare<float> c2(4.4,3.2);
cout<<c2.max()<<endl;
return 0;
}
我实在是看不出什么错误来了,请高手解答一下哈