vlad7576

up07-1(exception)

May 17th, 2020
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.46 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. class Exept
  4. {
  5. public:
  6.     std::string tmp;
  7.  
  8.     Exept() {}
  9.  
  10.     ~Exept()
  11.     {
  12.         if (!tmp.empty()) {
  13.             std::cout << tmp << std::endl;
  14.         }
  15.     }
  16. };
  17.  
  18. void func()
  19. {
  20.     Exept a;
  21.     try {
  22.         if (std::cin >> a.tmp) {
  23.             throw 1;
  24.         } else {
  25.             throw '1';
  26.         }
  27.     } catch (const int &a) {
  28.         func();
  29.     }
  30.     catch (...) {
  31.     }
  32. }
  33.  
  34. int main()
  35. {
  36.     func();
  37. }
Advertisement
Add Comment
Please, Sign In to add comment