次のプログラムは、常に「Error:double 10.2」を出力します。
私はなぜなのか理解していない。私によると、fun1() で int のみをスローできる場合、プログラムは (1) クラッシュ (2) するか、double を int に変更してからスローする必要があります。つまり、出力は「Error:int 10」になります。しかし、そうではありません。誰でも説明できますか??
void fun1() throw (int)
{
cout<<"3";
throw 10.2;
cout<<"4";
}
int main()
{
try { fun1(); }
catch(int i) { cout<<"Error:int" <<i <<endl;}
catch(double i) { cout << "Error:double" << i << endl; }
cout << endl;
return 0;
}