8
爲什麼在捕獲std :: bad_exception之後崩潰? (我正在使用VC7)捕獲異常後崩潰
#include "stdafx.h"
#include <exception>
int validateInt (int x) throw (int,std::bad_exception) {
if (0 == x) {
throw std::bad_exception("x");
}
return x;
}
class C {
int i;
public:
C(int);
};
C::C(int ii)
try : i(validateInt(ii)) {
std::cout << "I'm in constructor function body\n";
} catch (std::exception& e) {
std::cout << "I caught an exception...\n";
}
int _tmain(int argc, _TCHAR* argv[]) {
C a(0);
return 0;
}
這是如何編譯...? –
你是什麼意思?圍繞構建初始化列表的try-catch塊是合法的C++。 – anonymvs
哇。我從未見過它被使用過,也從未聽說過它。 –