https://www.cnblogs.com/msymm/p/9750787.html
简单来说,一个函数的输入参数类型不定,为了保证一个函数可对多个类型参数使用,改一个模板
1要实现声明
2使用 <>代替()
template <class numtype> //声明一个模板,虚拟类型名为numtype
class Compare //类模板名为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;
};