#include #include using namespace std; // g++ has a compiler error on the throw(...) void f() // throw(...) this is illegal, throw must reference a complete type, 15.4 { throw std::string( "wierd"); } class Whatever { public: Whatever() throw() : i(5) { i = 0; throw "ha"; } private: int i; }; void handler() { cout << "handler called" << endl; throw "foo"; } int main() { try { f(); } catch (std::string& str) { cout << str << endl; } catch (...) { cout << "something strange happened" << endl; } set_unexpected( handler); try { Whatever huh; } catch (...) { } return 0; }