#include <iostream>
#include <new>

class Exception { public: virtual char const *origin() { return "something else."; } };
class ExDivByZero : public Exception { public: char const *origin() { return "Divided by zero."; } };
class ExBadArgument : public Exception { public: char const *origin() { return "Bad argument."; } };
class ExCannotOpen : public Exception { public: char const *origin() { return "Cannot open."; } };
 
int main() {
  for(;;) {
    char c;
    if (std::cin >> c, c == 'd')
      break;
    try {
      switch (c) {
      case 'a':
        throw (new ExDivByZero());
      case 'b':
        throw (new ExBadArgument());
      case 'c':
        throw (new ExCannotOpen());
      }
    } catch (Exception *e) {
      std::cerr << e->origin() << std::endl;
      delete e;
    } catch (std::bad_alloc dmy) {
      std::cerr << "bad_aloc." << std::endl; 
      /* eating */
    }
  }
}
/* end */
