C++ 异常处理 terminate函数使用

2014-11-24 01:01:08 · 作者: · 浏览: 3

C++ 异常处理 terminate函数使用代码:


#include
using namespace std;


void terminator(){
cout << "I 'll be back!" < exit(0);
}


void (*old_terminate)() = set_terminate(terminator);



class B{
public :
class A{};
void f(){
cout<<"B::f()"< throw A();
}
~B(){
throw 'c';
}
};


int main(){
try{
B b;
b.f();
}catch(...){
cout<<"inside catch(...)"< }
return 0;
}