Under what circumstances are C++ destructors not going to be called?

前端 未结 8 874
-上瘾入骨i
-上瘾入骨i 2020-12-02 08:52

I know that my destructors are called on normal unwind of stack and when exceptions are thrown, but not when exit() is called.

Are there any other cases where my des

相关标签:
8条回答
  • 2020-12-02 09:41

    Another case they won't be called is if you are using polymorphism and have not made your base destructors virtual.

    0 讨论(0)
  • 2020-12-02 09:42

    abort terminates program without executing destructors for objects of automatic or static storage duration as Standard says. For other situations you should read implementation specific documents.

    0 讨论(0)
提交回复
热议问题