How can I determine if a C++ object has been deallocated?

前端 未结 6 1790
情话喂你
情话喂你 2020-11-29 13:38

I have a previous question that was answered in which I describe difficulties catching an exception when I try to access an object that has been deallocated by a third-party

6条回答
  •  攒了一身酷
    2020-11-29 13:57

    You can't. If the function you're using doesn't give you ways of knowing whether or not it deallocated the object itself, there's no way you can find out.

    Edit: Well, unless the object in question is an instance of your own class and you can modify the destructor like Adrian suggested.

提交回复
热议问题