#include <iostream>
using namespace std;
void func(int a)
{
if(a == 0)
{
throw string("a is error");
throw a;
}
}
int main()
{
try
{
func(0);
}
catch(int a)
{
cout << "a " << a << endl;
}
catch(const string &s)
{
cout << s << endl;
}
return 0;
}
$ ./a.out
a is error
标签:int,try,func,error,catch,异常,throw
From: https://www.cnblogs.com/zhangxuechao/p/16600771.html