template <typename T>
class Op
{
public:
T process(T v)
{
return v*v;
}
};
void main()
{
Op<int> opInt;
Op<double> opDouble;
cout<<opInt.process(5);
cout<<opDouble.process(0.3);
}
template <typename T>
class Op
{
public:
T process(T v)
{
return v*v;
}
};
void main()
{
Op<int> opInt;
Op<double> opDouble;
cout<<opInt.process(5);
cout<<opDouble.process(0.3);
}
原文:https://www.cnblogs.com/judes/p/8734914.html