5,531
社区成员
发帖
与我相关
我的任务
分享
template<typename T> class Singleton {
public:
static T& Instance()
{
static T theSingleInstance; //assumes T has a default constructor
return theSingleInstance;
}
};
class OnlyOne : public Singleton<OnlyOne> {
private:
OnlyOne(){}
OnlyOne(OnlyOne& rhs){}
friend class Singleton<OnlyOne>;
//..rest of interface defined here
};