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

前端 未结 6 1788
情话喂你
情话喂你 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 14:07

    You can't easily tell just by looking at the memory location if the object is still allocated or not. There might be some black magic tricks to do that, but a much cleaner way would be to build a call-back mechanism into the object's destructor.

提交回复
热议问题