正在加载图片...
15:26:27 例:指定异常的函数 void fun (int, double) void test(int, double) throw(int, double) const int intmax =100000 const double floatMax 1E12 void maino i void test(int i, double a fun(1020033.1415926); fun(5000,1.2638); if (i>intMax throw i: if (a>floatMax)throw a void fun int k, double x) try t test(k, x) catch(int Lcout < "Integer data is too large. < end1 catch(double) lcout < "Float data is too large. < end115:26:27 ➢例:指定异常的函数 void fun(int,double); void test(int,double) throw(int,double); const int intMax = 100000; const double floatMax = 1E12; void main(){ fun(102003,3.1415926); fun(5000,1.2e38); } void fun(int k,double x){ try{ test(k,x); }catch(int) {cout << "Integer data is too large." << endl;} catch(double) {cout << "Float data is too large." << endl;} } void test(int i,double a) { if(i>intMax) throw i; if(a>floatMax)throw a; }
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有