#include <iostream>
using namespace std;
int main()
{
int a =0;
int b = 1;
try
{
if(a!=b)
throw runtime_error("sdfsdfsf!");
} catch (runtime_error err) {
cout<< err.what();
}
cout << "Hello World!" << endl;
return 0;
}
就是为一旦出错提供一种选择,如果throw没有被catch,进程会被terminate