#include <strstream> #include <iostream> #include <stack> using namespace std; int main() { void f1(); try { f1(); } catch(double) { cout << "OK0" << endl; } cout << "end0" << endl; return 0; } void f1() { void f2(); try{f2();} catch(char) { cout << "OK1" << endl; } cout << "end1" << endl; } void f2() { void f3(); try{f3();} catch(int) { cout << "OK2" << endl; } cout << "end2" << endl; } void f3() { double a = 0; try { throw a; } catch (float) // 結果OK0 end0 // catch (double) // OK3 end3 end2 end1 end0 { cout << "OK3" << endl; // throw; // 將a直接拋出,最後結果 OK3 OK0 end0 } cout << "end3" << endl; }