#include #include using namespace std; class test : public exception { public: test(const string &msg) : msg(msg) { } virtual const char* what() const throw() { return msg.c_str(); } ~test() throw() {}; private: string msg; }; int main(int argc, char** argv) { try { throw test("LOL"); } catch(test &e) { cout << e.what() << endl; } return 0; }