I have a simple question about objects and exception handling.

What happens to an object after its thrown? Does the implementation take of cleaning up that object or should I be aware of any situations that may require extra care...I've read this from - Inside The C++ Object Model by Stanley B. Lippman pg 261

"When an exception is thrown, the exception object is created and placed generally on some form of exception data stack"

This is great to know but I can't find any mention of what happens to that object after the exception is finished...Could someone please enlighten me...Thanks.

Recommended Answers

All 2 Replies

I can't find any mention of what happens to that object after the exception is finished

Finished by being caught and handled, or finished by being unhandled? In the former case, the destructor is properly called and the object ends after the final exception handler completes. In the latter case, abort is called, which is a hard terminate on the program.

Finished by being caught and handled, or finished by being unhandled? In the former case, the destructor is properly called and the object ends after the final exception handler completes. In the latter case, abort is called, which is a hard terminate on the program.

I meant the former and thank-you for clearing that up

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.