#include #include using namespace std; class MyExceptionBase { public: string messg ; MyExceptionBase( string str1 ) { messg = str1 ; } }; class MyException : public MyExceptionBase { public: MyException( string str1 ) : MyExceptionBase( str1 ) { } }; int main() { try { throw MyException("Error") ; } catch ( MyExceptionBase& e1 ) { cout << e1.messg << endl ; } catch ( MyException& e1 ) { cout << e1.messg << endl ; } return 0; }