指定抛异常类型

1 #include <iostream> 2 using namespace std; 3 4 void show() throw (int) 5 { 6 throw double(2); 7 } 8 9 int main() 10 { 11 try{ 12 show(); 13 } 14 catch (double eobj) 15 { 16 cout << eobj << endl; 17 } 18 catch (int eobj) 19 { 20 cout << eobj << endl; 21 } 22 23 return 0; 24 }

浙公网安备 33010602011771号