c++的模板
c++泛型编程
# include <iostream>
using namespace std;
template <typename T>
class op
{
public:
T process(T v)
{
return v * v;
}
};
int main()
{
op<int> opInt;
cout << opInt.process(5) << endl;
op<double>opDouble;
cout << opDouble.process(1.1) << endl;
cin.get();
return 0;
}