单件(Singleton)模式的实现
熟悉设计模式的朋友一定知道著名的Singleton吧,如果不知道的话那就先去拜读一下GoF的大作吧,我在这里就不详细介绍了。 直接给大家共享出我们的实现方法,使用的是C++的template。
// singleton.h
#ifndef _SINGLETON_H_
#define _SINGLETON_H_
template class Singleton
{
protected:
Singleton() {}
Singleton( const Singleton & ) {}
Singleton &operator = (Singleton &) {}
...