C++ 单例(Singleton)
Singleton.h
#ifndef NET_SINGLETON_H
#define NET_SINGLETON_H
template<typename T>
class Singleton
{
public:
static T &instance()
{
static T t;
return t;
}
Singleton() = delete;
~Singleton() = delete;
Singleton(const Singleton &) = delete;
Singleton &operator=(const Singleton &) = delete;
};
#endif //NET_SINGLETON_H