Running method while destroying the object

前端 未结 8 1575
抹茶落季
抹茶落季 2021-01-12 22:49

A few days ago my friend told me about the situation, they had in their project. Someone decided, that it would be good to destroy the object of NotVerySafeClass

8条回答
  •  一整个雨季
    2021-01-12 23:18

    What you need is a sound ownership policy. Why is the code destroying the object when it is still needed?

    Without more details about the code, a std::shared_ptr would probably solve this issue. Depending on your specific situation, you may be able to solve it with a more lightweight policy.

提交回复
热议问题