我好不明白
#include <iostream>
using namespace std;
int a=30 ,b=20;
void ma( int=1,int=2 ) throw (double&); //规定抛出double&异常
void main ()
{try
{ma( a,b);
}
catch (int& d)
{d++;
cout<<"d=" <<d<<"\n";
}
cout << "==========int==============\n";
}
void ma (int a,int b) throw (double&)
{try {cout <<"start\n";
if (a > b)
throw a ;
cout << "close\n";
}
catch (double& d)
{d++;
cout<<"d=" <<d<<"\n";
}
cout << "==========double=============\n";
}
居然能够编译执行成功,我好不明白,望指教!!!!!!!
void ma()规定抛出double&异常,但在实际调用是却抛出了int&异常,书上说系统会调用标准库的unexpected()结束,但vc6好象没看见规定,直接调用了catch (int&)来处理这个异常,我好不明白!!!!!!!!!!!!!!!!!