C++二级上机改错题.docVIP

  • 37
  • 0
  • 约2.05万字
  • 约 22页
  • 2017-11-26 发布于河南
  • 举报
C二级上机改错题

上机改错题 1、 该程序运行时有错误,请改正错误,使得程序正常运行,并且要求最后一个catch() 必须抛出执行的任何异常。 程序通过抛出异常输出: error 0 ERROR 注意:不要改动main函数,不能增行或删行,也不能更改程序的结构,错误的语句在//******error******的下面。 #include iostream.h int main() { try { throw(error); } //********error******** catch(char s) { coutsendl; } try { throw((int)0); } //********error******** catch() { coutiendl; } try { throw(0); throw(error); } //********error******** catch() { coutERRORendl; } return 0; } 【答案】 (1)catch(char* s) (2)catch(int i) (3)catch(...) 【审题分析】 本程序是对各种异常信息的处理。try-catch的结构中,catch子句用来捕捉异常的信息。 【解题思路】 (1)第1个标识前的异常

文档评论(0)

1亿VIP精品文档

相关文档