C++: If an exception is thrown, are objects that go out of scope destroyed?
问题 Normally it would be destructed upon the scope ending.. I could see issues occurring if exceptions were thrown though. 回答1: Yes. C++ Standard n3337 15 Exception handling § 15.2 Constructors and destructors 1) As control passes from a throw-expression to a handler, destructors are invoked for all automatic objects constructed since the try block was entered . The automatic objects are destroyed in the reverse order of the completion of their construction. 2) An object of any storage duration