#include #include void notstand() { std::cerr << "... wird es auch schief gehen.\n"; throw std::bad_exception(); } class X {}; class U {}; void harmlos() throw(U) // wirklich ??? { throw X(); } int main() { std::unexpected_handler old = std::set_unexpected(notstand); try { std::cout << "Was schiefgehen kann, ..." << std::endl; harmlos(); // unexpected(); } catch(bad_exception& ) { std::cerr << "\t(Murphy's Gesetz)\n"; } catch(...) { std::cerr << "...und zwar anders, als man erwartet.\n"; } return 0; } // Bugs ???: // minGW g++ 2.95 : ...wird schief gehen, danach abnormal program termination () // (exception handling in experimental stage) // M$ VC++ 6.0 : ignoriert throw-Deklaration, fängt X-Ausnahme ab