Chinaunix首页 | 论坛 | 博客
  • 博客访问: 8296162
  • 博文数量: 1413
  • 博客积分: 11128
  • 博客等级: 上将
  • 技术积分: 14685
  • 用 户 组: 普通用户
  • 注册时间: 2006-03-13 10:03
个人简介

follow my heart...

文章分类

全部博文(1413)

文章存档

2013年(1)

2012年(5)

2011年(45)

2010年(176)

2009年(148)

2008年(190)

2007年(293)

2006年(555)

分类: C/C++

2010-09-01 23:43:07

c++抛出异常示例:

//#include


//using namespace std;


class MyError {
    const char* const data;
    public:
        MyError(const char* const msg = 0) : data(msg) {}
};

void f() {
    throw MyError("something bad happend");
}

int main()
{
    f();
    return 0;
}


运行结果:

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.

Process returned 3 (0x3)   execution time : 0.031 s
Press any key to continue.


阅读(1322) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~

chinaunix网友2010-09-03 15:32:35

Download More than 1000 free IT eBooks: http://free-ebooks.appspot.com