构造函数的初始化列表抛出异常

即使捕获了,依然会上抛。具体见:http://blog.csdn.net/hikaliv/article/details/4460180

#include <iostream>
using namespace std;

class A
{
public:
    A(int a) try: m_p(new char[a])
    {
    }
    catch(...)
    {
        m_p = NULL;
        cout << "catch1..." << endl;
    }

    ~A()
    {
        delete m_p;
    }
char * m_p;
};

int main()
{
    try
    {
        A a(-2);
    }
    catch(...)
    {
        cout << "catch2..." << endl;
    }
    return 0;
}

原文地址:https://www.cnblogs.com/sfqtsh/p/5172806.html