It's illegal to throw an exception from a function like this?
In Eclipse it work...
So it's true? and we can throw internal object in throwing exceptions?
class Bad {
int i;
public:
void what() { cout << "exp" << i; }
};
class A {
public:
void f() {
Bad e;
throw e;
} // e are deleted by d'tor?
};
int main() {
A a;
try {
a.f();
} catch (Bad& e) // What happen here? we catch reference to some object that
// was deleted by Bad dt'or
{
cout << "in catch";
e.what(); // what happen here?
}
return 0;
}