首页 > 代码库 > C++异常处理机制----C++primer4

C++异常处理机制----C++primer4

 

#include<iostream>#include<stdexcept>#include<exception>using namespace std;int main(){    int a,b;    a=-3;    b=2;    try    {        if((a+b)<0)            throw runtime_error("have something wrong!!!");        cout<<a+b<<endl;    }    catch(runtime_error err )    {          cout<< err.what();        cout<<a<< <<b<<endl;    }    system("pause");    return 1;}

 

C++异常处理机制----C++primer4