Exception Terminate

U

utab

Dear all,

I have been reading on exceptions and had a very simple exception
example with terminate. But one point was fuzzy to me. Why is the
block not executed. Because of the dtor throws another exception.

#include <exception>
#include <iostream>
#include <cstdlib>
using namespace std;

void terminator() {
cout << "I'll be back!" << endl;
exit(0);
}

void (*old_terminate)()
= set_terminate(terminator);

class Botch {
public:
class Fruit {};
void f() {
cout << "Botch::f()" << endl;
throw Fruit();
}
~Botch() { throw 'c'; }
};

int main() {
try{
Botch b;
b.f();
} catch(...) {
cout << "inside catch(...)" << endl; // Why are not these written
on the output
}
}

Output

Botch::f()
I'll be back!

Regards,
 
U

utab

Sorry Again, I should first have had a look at the FAQ. I found that in
the Exception Handling part.

Ragards
 
U

utab

Sorry Again, I should first have had a look at the FAQ. I found that in
the Exception Handling part.

Regards
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,074
Latest member
StanleyFra

Latest Threads

Top