From 83afdf27bb443c71fe9c95994283be2a4a500afb Mon Sep 17 00:00:00 2001 From: p68710245 Date: Sat, 11 May 2024 11:37:16 +0800 Subject: [PATCH] Add nest_exception.cpp --- nest_exception.cpp | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 nest_exception.cpp diff --git a/nest_exception.cpp b/nest_exception.cpp new file mode 100644 index 0000000..5848c4a --- /dev/null +++ b/nest_exception.cpp @@ -0,0 +1,35 @@ +#include +#include +using std::cin, std::cout, std::string; + +void C() +{ + cout << "start C\n"; + throw -1; + cout << "End C\n"; +} +void B() +{ + cout << "start B\n"; + C(); + cout << "End B\n"; +} + +void A() +{ + cout << "start A\n"; + B(); + cout << "End A\n"; +} + +int main() +{ + try + { + A(); + } + catch (int) + { + cout << "main 处理了 int\n"; + } +} \ No newline at end of file