正在加载图片...
5:26:7 例:不同类型的异常测试 int test(char *p, double e, int a) int f =1 try( if(*p>=0′&*p<=′9′) throw*p; if(e<o e>20000)throw e: if(a<18 a>)throw a catch char s) [f=0; cout < "password error: < s < end1 catch(double e) If =0; cout < earnings error: < e << end1 catch(int a) If =0; cout < "age error: < a << end1 return f15:26:27 例:不同类型的异常测试 int test(char *p,double e,int a){ int f = 1; try{ if(*p>='0' && *p<='9') throw * p; if(e<0 || e>20000)throw e; if(a<18 || a>70)throw a; } catch(char s) {f=0;cout << "password error: " << s << endl;} catch(double e) {f = 0;cout << "earnings error: " << e << endl;} catch(int a) {f = 0;cout << "age error: " << a << endl;} return f; }
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有