Normally it would be destructed upon the scope ending.. I could see issues occurring if exceptions were thrown though.
相关问题
- Sorting 3 numbers without branching [closed]
- How to compile C++ code in GDB?
- Why does const allow implicit conversion of refere
- thread_local variables initialization
- What uses more memory in c++? An 2 ints or 2 funct
相关文章
- Class layout in C++: Why are members sometimes ord
- How to mock methods return object with deleted cop
- How to add external file to application files ( cl
- Which is the best way to multiply a large and spar
- C++ default constructor does not initialize pointe
- Selecting only the first few characters in a strin
- What exactly do pointers store? (C++)
- Converting glm::lookat matrix to quaternion and ba
Yes any scope bound variables will be destroyed.
In this example
a
's destructor would be called when the exception was thrown as the stack unwound, but the memory pointed to byb
would be leaked since it would never reach thedelete
call. This is one of the many reasons why RAII is so helpful.Yes. When you leave a scope (whether normally or via exception) objects local to that scope are destroyed. This is the basic fact that makes RAII/SBRM work.
Yes.
C++ Standard n3337
15 Exception handling
§ 15.2 Constructors and destructors
example: