|
학교 교수님에게서 다음 코드를 받았는데, 신기하게도 throw하는 값이 int, double에 관계없이 무조건 double catch handler만 출력이 되네요.
그 이유에 대해서 알고 싶습니다.
#include <stdexcept>
using std::runtime_error;
#include <iostream>
using std::cout;
using std::cin;
using std::cerr;
using std::endl;
int main()
{
try
{
int a = 7;
double b = 9.9;
throw a < b ? a : b;
}
catch(int x)
{
cerr << "Int handler is activated!" << endl;
}
catch(double x)
{
cerr << "Double handler is activated!" << endl;
}
return 0;
}
|