类模板定义:
#include <iostream>
using namespace std;
template<class T>
class test
{
private:
T n;
const T i;
public:
Test():i(0){}
Test(T k);
~Test(){}
void print();
T operator+(T x);
}
template<class T>
void Test<T>::print()
{
cout<<"n = " <<n<<endl;
cout<<"i = " <<i<<endl;
}
template<class T>
Test<T>::Test(T t):i(k)
{
n =k;
}
template<class T>
T Test<T>::opertor +(T x)
{
return n+x;
}