异常处理上海财经大学.pptVIP

  • 0
  • 0
  • 约5.66千字
  • 约 24页
  • 2018-05-09 发布于天津
  • 举报
异常处理上海财经大学

class?myexception:public?exception{ ? public: ? virtual?const?char?*?what()?const; ? }; ? const?char*?myexception::what()?const { ? return?myException; ? } ? class?A{ ? public: ? A( ){ } ? void?f( )?throw( ){ ? throw?new?myexception(); ? } ?}; ? 值传递示例 int?main(){ ? A?a; ? try { ? a.f(); ? } catch(exception*?pexc){ ? coutpexc-what(); ? delete?pexc; ? } ? } 运行结果:myException class?myexception:public?exception{ ? public: ? virtual?const?char?*?what()?const; ? }; ? const?char*?myexce

文档评论(0)

1亿VIP精品文档

相关文档