simple 单例


Message* Message::m_pInstance = 0;//类外初始

Message::Message()
{

}

Message::~Message()
{
    if (m_pInstance != 0)
    {
        delete InstanceServer::m_pInstance;
        m_pInstance = 0;
    }
}


Message*Message::getInstance()
{
    if (m_pInstance == 0)
    {
        m_pInstance = new Message();
    }
    return m_pInstance;
}

void Message::deleteInstance()
{
    if (m_pInstance != nullptr)
    {
        delete m_pInstance;
        m_pInstance = nullptr;
    }
}

 

posted @ 2018-06-14 13:51  风来风往风伤(TiAmo)  阅读(186)  评论(0编辑  收藏  举报