이번 글은 Use of std::bad_exception 을 보고 작성하였습니다. 아래 프로그램의 실행 결과는 무엇일까요? void my_unexpected() { if (!uncaught_exception()) cerr throw; } void my_terminate() { cerr } void func() { cerr } void g() throw (int) { throw 1.0; // throws double } int main() { set_unexpected (my_unexpected); set_terminate (my_terminate); atexit (func); try { g(); } catch (int) { cerr } catch (bad_exception& e) { cerr } return 0; } 한 단계씩 살펴보도록 하겠습니다. 먼저 main() 함수의 처음 세 라인은 각각 unexpected, terminate 함수와 프로그램 종료시 호출될 함수를 등록하고 있습니다. 그리고 C++03에서 unexpected() 함수와 관련된 내용은 다음과 같습니다. exception-specification을 가진 함수에서 exception-specification에 리스트되어 있지 않은 예외를 던지면 호출된다. unexpected 함수안에서 exception-specification에 있는 예외를 던지면 해당 handler를 찾아 처리한다. unexpected 함수안에서 rethrow 하거나 exception-specification에 없는 예외를 던지면... exception-specification에 std::bad_exception이 있으면 던져진 예외는 std::bad_exception으로 치환되어 처리된다. exception-specification에 std::bad_exception이 없으면 terminate() 함수가 호출된다. 이제 main() 함...