Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <exception>
- #include <cstring>
- #include <cstdarg>
- class MyException : public std::exception {
- private:
- char description[256];
- public:
- MyException (const char* format, ...) {
- char buffer[256];
- strcpy(buffer, "MyException: ");
- strcat(buffer, format);
- va_list args;
- va_start(args, format);
- vsprintf(description, buffer, args);
- va_end(args);
- }
- virtual const char* what() const throw() {
- return description;
- }
- };
Add Comment
Please, Sign In to add comment