template<typename T1>
class MyObjectT
{
public:
template<typename T2>
void Foo(T2 v);
};
template<typename T1>
template<typename T2>
void MyObjectT<T1>::Foo(T2 v)
{
cout << "Foo(" << v << ")" << endl;
}
#include <iostream>
class Single{
public:
static Single* ShareInstance();
static void ReleaseInstance();
template<class Tex>//要成员函数实现模版用法,而类不是模版类。需要写成这个格式
void SwapEx(Tex &obj1, Tex &obj2){
}
private:
Single();
~Single();
Single(const Single &other);
Single& operator=(const Single &other);
private:
static Single *m_pObj;
};
需要放在同一个文件