Guest User

Untitled

a guest
May 23rd, 2018
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. #include <exception>
  2. #include <cstring>
  3. #include <cstdarg>
  4.  
  5. class MyException : public std::exception {
  6. private:
  7. char description[256];
  8. public:
  9. MyException (const char* format, ...) {
  10. char buffer[256];
  11. strcpy(buffer, "MyException: ");
  12. strcat(buffer, format);
  13.  
  14. va_list args;
  15. va_start(args, format);
  16. vsprintf(description, buffer, args);
  17. va_end(args);
  18. }
  19.  
  20. virtual const char* what() const throw() {
  21. return description;
  22. }
  23. };
Add Comment
Please, Sign In to add comment