Last Updated on May 3, 2022 by Admin 3
What is the output of the following snippet?
#include <iostream> #include <exception> #include <stdexcept> using namespace std; class X : public runtime_error { public: X() : domain_error("0") {}; }; void z() throw(X) { X x; throw x; cout << 1; } int main(void) { X x; try { z(); } catch(X &i) { cout << 1; } catch(domain_error &i) { cout << 0; } return 0; }
0
- Compilation fails
- Execution fails
1