//很简单的一个嵌套式的异常
---------摘自谭浩强的C++.
#include <iostream>
using namespace std;
void f1();
void f2();
void f3();
int main()
{
try
{
f1();
}
catch (double)
{
cout<<"OK0"<<endl;
}
cout<<"end0"<<endl;
getchar();
return 0;
}
void f1()
{
try
{
f2();
}
catch(char)
{
cout<<"OK1"<<endl;
}
cout<<"end1"<<endl;
}
void f2()
{
try
{
f3();
}
catch (int)
{
cout<<"OK3"<<endl;
}
cout<<"end2"<<endl;
}
void f3()
{
double a=0;
try
{
throw a;
}
catch(double)
{
cout<<"OK3"<<endl;
throw;
}
cout<<"end3"<<endl;
}