标签:
捕获异常
double divideNumber(double num1,double num2){ if (num2==0) { throw exception(); } return num1/num2; }
try{ cout << divideNumber(1,3) << endl; cout << divideNumber(1,0) << endl; }catch(const exception& exp) { cout << "An exception was caught !" << endl; }
void addNum(int& a) { a++; }
标签:
原文地址:http://blog.csdn.net/qq285016127/article/details/45244287