| 4 | #include "Troubles.h" |
| 5 | |
| 6 | int main() |
| 7 | { |
| 8 | for (int i {}; i < 7; ++i) |
| 9 | { |
| 10 | try |
| 11 | { |
| 12 | if (i == 3) |
| 13 | throw Trouble{}; |
| 14 | else if (i == 5) |
| 15 | throw MoreTrouble{}; |
| 16 | else if (i == 6) |
| 17 | throw BigTrouble{}; |
| 18 | } |
| 19 | catch (const Trouble& t) |
| 20 | { |
| 21 | //std::cout << "Trouble object caught: " << t.what() << std::endl; |
| 22 | std::cout << typeid(t).name() << " object caught: " << t.what() << std::endl; |
| 23 | } |
| 24 | std::cout << "End of the for loop (after the catch blocks) - i is " << i << std::endl; |
| 25 | } |
| 26 | } |