#include <iostream>
class ExceptionBase {
};
class MyException : public ExceptionBase {
};
int main()
{
try
{
throw MyException();
}
catch (MyException const& e) {
std::cout<<"catch 1"<<std::endl;
}
catch (ExceptionBase const& e) {
std::cout<<"should not catch 1"<<std::endl;
}
////////
try
{
throw MyException();
}
catch (ExceptionBase const& e) {
std::cout<<"catch 2"<<std::endl;
}
catch (...) {
std::cout<<"should not catch 2"<<std::endl;
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKY2xhc3MgRXhjZXB0aW9uQmFzZSB7Cn07CgpjbGFzcyBNeUV4Y2VwdGlvbiA6IHB1YmxpYyBFeGNlcHRpb25CYXNlIHsKfTsKCmludCBtYWluKCkKewoJdHJ5Cgl7CgkJdGhyb3cgTXlFeGNlcHRpb24oKTsKCX0KCWNhdGNoIChNeUV4Y2VwdGlvbiBjb25zdCYgZSkgewoJCXN0ZDo6Y291dDw8ImNhdGNoIDEiPDxzdGQ6OmVuZGw7Cgl9CgljYXRjaCAoRXhjZXB0aW9uQmFzZSBjb25zdCYgZSkgewoJCXN0ZDo6Y291dDw8InNob3VsZCBub3QgY2F0Y2ggMSI8PHN0ZDo6ZW5kbDsKCX0KCQoJLy8vLy8vLy8KCXRyeQoJewoJCXRocm93IE15RXhjZXB0aW9uKCk7Cgl9CgljYXRjaCAoRXhjZXB0aW9uQmFzZSBjb25zdCYgZSkgewoJCXN0ZDo6Y291dDw8ImNhdGNoIDIiPDxzdGQ6OmVuZGw7Cgl9CgljYXRjaCAoLi4uKSB7CgkJc3RkOjpjb3V0PDwic2hvdWxkIG5vdCBjYXRjaCAyIjw8c3RkOjplbmRsOwoJfQoKCXJldHVybiAwOwp9