Advertisement
Guest User

Untitled

a guest
Nov 5th, 2017
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <exception>
  3.  
  4. struct noFileException : public std::exception {
  5. const char *message() const throw () {
  6. return "Exception throwed.\n";
  7. }
  8. };
  9.  
  10. class someClass {
  11. public:
  12. someClass() {
  13. throw new noFileException;
  14. }
  15.  
  16. };
  17.  
  18. int main() {
  19.  
  20. try {
  21. someClass *myClass = new someClass();
  22. }
  23. catch(noFileException e) {
  24. printf("exception: %s\n", e.message());
  25. }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement