c 函数模版与类模版。
templatevoid swapfunction(t &first, t &second){ }//函数模版
template
class ctemplate{
public:
void swap(t &first, t &second){
}
};
#includeclass single{ public: static single* shareinstance(); static void releaseinstance(); template //要成员函数实现模版用法,而类不是模版类。需要写成这个格式 void swapex(tex &obj1, tex &obj2){ } private: single(); ~single(); single(const single &other); single& operator=(const single &other); private: static single *m_pobj; }; single* single::m_pobj = null; single* single::shareinstance(){ if (null == m_pobj) { single obj; m_pobj = new single(); } return m_pobj; } void single::releaseinstance(){ if (m_pobj) { delete m_pobj; m_pobj = null; } } single::single(){ } single::~single(){ }