电子工业出版社C程序设计基础第3版答案:11answer1.docVIP

  • 18
  • 0
  • 约 2页
  • 2015-09-09 发布于浙江
  • 举报

电子工业出版社C程序设计基础第3版答案:11answer1.doc

第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;

文档评论(0)

1亿VIP精品文档

相关文档