文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>C++中异常处理器

C++中异常处理器

时间:2010-09-01  来源:riverbird2005

一个try...catch示例:

#include <iostream>
#include <csetjmp>


using namespace std;

class Rainbow {
    public:
        Rainbow() {cout << "Rainbow()" << endl;}
        ~Rainbow() {cout << "~Rainbow()" << endl;}
};


void oz() {
    Rainbow rb;
    for(int i = 0; i < 3; i++) {
        cout << "there's no place like home" << endl;
    }
    throw 47;
}

int main()
{

    try{
        cout << "tornado, witch, muchkins..." << endl;
        oz();

    }
    catch (int){
        cout << "Autie Em!"
             << " I had the strangest dream..."
             << endl;
    }
    return 0;
}


输出: tornado, witch, muchkins... Rainbow() there's no place like home there's no place like home there's no place like home ~Rainbow() Autie Em! I had the strangest dream...
Process returned 0 (0x0)   execution time : 0.094 s Press any key to continue.

相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载