- 18
- 0
- 约 2页
- 2015-09-09 发布于浙江
- 举报
第11章 异常处理
11.1阅读下列程序,写出执行结果
1.#include iostream.h
int a[ 10 ] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
int fun( int i );
void main()
{ int i ,s = 0;
for( i = 0; i = 10; i++ )
{ try
{ s = s + fun( i ) ; }
catch( int )
{ cout 数组下标越界! endl; }
}
cout s = s endl;
}
int fun( int i )
{ if ( i = 10 )
throw i ;
return a[i] ;
}
答案:
数组下标越界!
S=55
2.#include iostream.h
void f();
class T
{ public:
T()
{ cout constructor endl;
try
{ throw exception; }
catch( char * )
{ cout exception1 endl; }
throw exception;
您可能关注的文档
最近下载
- 灯塔施工方案.docx
- 2021年一级注册消防工程师继续教育题库--消防应急照明考试.pdf VIP
- 高等职业教育专科英语课程词汇表(2021版).pdf VIP
- AP宏观经济学 2012年真题 (选择题+问答题) AP Macroeconomics 2012 Released Exam and Answers (MCQ+FRQ).pdf VIP
- 口渴了-朋友帮你.ppt VIP
- 2019年注册消防工程师继续教育题库.pdf VIP
- (完整word版)2019注册消防工程师继续教育三科试题及答案.doc VIP
- 高钠血症多学科决策模式中国专家共识(2025版).docx VIP
- 2019年消防继续教育试题汇总及答案.docx VIP
- 2019年一级注册消防工程师继续教育三科题库+答案 .pdf VIP
原创力文档

文档评论(0)