How to deallocate object pointer in vector?

后端 未结 7 1378
野趣味
野趣味 2021-02-06 12:30

I have ;

class object {
                    // any private datas token in heap area 
             public : 
                   ~object () ; 

};
<
7条回答
  •  北恋
    北恋 (楼主)
    2021-02-06 13:05

    The destructor function should contain all necessary stuffs to free up the memory object is occupying.

    Since this object pointer is stored inside a vector, you should remove reference to it after destroying it. That is, erase that object* from the vector.

提交回复
热议问题