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