how to free memory from a set

后端 未结 3 1770
庸人自扰
庸人自扰 2021-01-24 16:46

I got a set that includes pointers to an allocated memory, I am using the clear method forexample : setname.clear(); and the set itself is getting cleared and his p

3条回答
  •  执念已碎
    2021-01-24 17:19

    Clear() only removes the pointers not the object it points to. You'll have either to iterate on each object before removing it to delete it, or use something like std::tr1::shared_ptr (also in Boost).

提交回复
热议问题