Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- void funcThree()
- {
- std::cout << "FuncThree Started!\n";
- //throw "Oops!";
- //throw 'Z';
- throw 42;
- std::cout << "FuncThree Ended!\n";
- }
- void funcTwo()
- {
- std::cout << "FuncTwo Started!\n";
- try
- {
- funcThree();
- }
- catch (char ex)
- {
- std::cout << "FuncTwo catches CHAR exception!\n";
- }
- std::cout << "FuncTwo Ended!\n";
- }
- void funcOne()
- {
- std::cout << "FuncOne Started!\n";
- try
- {
- funcTwo();
- }
- catch (float ex)
- {
- std::cout << "FuncOne catches FLOAT exception!\n";
- }
- catch (bool ex)
- {
- std::cout << "FuncOne catches BOOL exception!\n";
- }
- catch (int ex)
- {
- std::cout << "FuncOne catches INT exception!\n";
- }
- std::cout << "FuncOne Ended!\n";
- }
- int main()
- {
- std::cout << "Main Started!\n";
- try
- {
- funcOne();
- }
- catch (int x)
- {
- std::cout << "MAIN catches INT exception!\n";
- }
- catch (double x)
- {
- std::cout << "Double exception " << x << '\n';
- }
- catch (float x)
- {
- std::cout << "float exception " << x << '\n';
- }
- std::cout << "Main NORMALLY works again!\n";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement