Reset an object without invoking copy constructor?

后端 未结 2 1361
南方客
南方客 2021-01-23 11:23

I have an object that cannot be copied, a NetGame because it has a stringstream in it.

I have it declared in my class as:

NetGame m_game;
2条回答
  •  伪装坚强ぢ
    2021-01-23 12:05

    You can just write a reset method for class NetGame.

    void NetGame::reset()
    {
    /*u can just reset the attribute u need*/
    }
    

    Then you can invoke the method in the setAcitvity function.

    void ServerTable::setActive( bool active )
    {
        //reset for now
        if(m_active && !active)
        {
            m_inProgress = false;
        }
        m_active.reset();
    }
    

提交回复
热议问题