#include #include class Exception : public std::exception { public: Exception() { } virtual ~Exception() throw() { } virtual const char *what() { return _message.c_str(); } protected: const std::string _message; }; class FooException : public Exception { public: FooException() : _message("FooException") { } virtual ~FooException() throw() { } protected: const std::string _message; }; void throw_foo() { throw FooException(); } int main() { throw_foo(); return 0; }