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,
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,