您的位置:首页 > 其它

第15周-阅读项目2-异常处理&&命名空间

2015-06-17 20:41 246 查看
问题及代码:

#include <iostream>
using namespace std;
void f();
class T
{
public:
    T( )
    {
        cout<<"constructor"<<endl;
        try
        {
            throw "exception";
        }
        catch(char*)
        {
            cout<<"exception"<<endl;
        }
        throw "exception";
    }
    ~T( )
    {
        cout<<"destructor";
    }
};
int main()
{
    cout<<"main function"<< endl;
    try
    {
        f( );
    }
    catch(char *)
    {
        cout<<"exception2"<<endl;
    }
    cout<<"main function"<<endl;
    return 0;
}
void f( )
{
    T t;
}


运行结果:



知识点总结:

异常处理。

学习心得:

(⊙o⊙)…感觉这个程序不太对阿,不是只有木有声明出来的情况才会调用系统的terminnate来终止嘛。。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: