标签:异常捕获 catch try turn ret int 异常 其他 row
int myDevide(int a, int b)
{
if (b == 0)
{
//throw - 1;//抛出int类型异常
throw 3.13;
}
return a / b;
}
void test01()
{
int a = 10;
int b = 0;
try {
myDevide(a, b);
}
catch (int)
{
cout << "int类型异常捕获" << endl;
}
catch (double) {
//throw;可以继续向上抛出
cout << "double异常捕获" << endl;
}
catch (...){
cout<<"其他类型异常捕获"<<endl;
}
}
标签:异常捕获 catch try turn ret int 异常 其他 row
原文地址:https://www.cnblogs.com/lodger47/p/14705189.html