C++模版类是创建
#include <iostream> using namespace std; template<typename T>class COperation { public: COperation(T a, T b){this->m_a = a; this->m_b = b;} COperation(void){}; ~COperation(void){}; //加法 T Add(T a, T b){return a + b;}; //减法 T Subtract(T a, T b){ a - b;} private: T m_a; T m_b; }; void main() { COperation<int> intMy(100,10); cout << "sum:" << intMy.Add(1000,10) << endl; cout<< "subtract:" << intMy.Subtract(1000, 10) << endl; int wait; cin >> wait; }