美文网首页
第十章 异常处理和跟踪

第十章 异常处理和跟踪

作者: ie大博 | 来源:发表于2016-11-15 16:22 被阅读0次

    异常的简单应用

    #include<iostream>
    #include<vector>
    using namespace std;
    int main()
    {
        int n=1;
        try//这个位置相当于一个判断
        {
            cout<<"begin"<<endl;
            if(n==1)
            throw 1;//把一返还给catch
            cout<<"after"<<endl;
        }
        catch(int)//catch接受throw给的内容
        {
            cout<<"catch"<<endl;
        }
          //  catch(...)//其意义是全都能抓取
        cout<<"end"<<endl;
        return 0;
    }
    

    相关文章

      网友评论

          本文标题:第十章 异常处理和跟踪

          本文链接:https://www.haomeiwen.com/subject/jpxlpttx.html