23种设计模式
//单例模式
class Singleton
{
public:
struct Inner {
~Inner() {
if (nullptr != m_pValue)
{
delete m_pValue;
m_pValue = nullptr;
}
}
};
static Singleton& InitInstance()
{
if (nullptr == m_pValue)
{
m_pValue = new Singleton;
static Inner objInner;
}
return *m_pValue;
}
bool operator== (Singleton& rhs) {
return m_pValue == rhs.m_pValue;
}
private:
static Singleton* m_pValue;
};