#include<iostream>usingnamespacestd;classX...{public:classTrouble...{};classSmall:publicTrouble...{};classBig:publicTrouble...{};voidf()...{throwBig();}};intmain()...{Xx;try...{x.f();}catch(X::Trouble&)...{cout<<"caughtTrouble"<<endl;//Hiddenbyprevioushandler:}catch(X::Small&)...{cout<<"caughtSmallTrouble"<<endl;}catch(X::Big&)...{cout<<"caughtBigTrouble"<<endl;}catch(...)...{cout<<"anexceptionwasthrown"<<endl;}}/**////:~ 结果是catch基类也能捕获子类的异常。再rethrow一次 #include<iostream>usingnamespacestd;classX...{public:classTrouble...{};classSmall:publicTrouble...{};classBig:publicTrouble...{};voidf()...{throwBig();}};intmain()...{Xx;try...{try...{x.f();}catch(X::Trouble&)...{cout<<"caughtTrouble"<<endl;throw;}catch(X::Small&)...{cout<<"caughtSmallTrouble"<<endl;}catch(X::Big&)...{cout<<"caughtBigTrouble"<<endl;}}catch(...)...{cout<<"rethrowcaught"<<endl;}}/**////:~ 可以跑,但是有警告,warning: exception of type `X::Small' will be caught。。。。。。。不晓得原因。