即使捕获了,依然会上抛。具体见: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; }
时间: 2024-10-12 23:30:13