抛出异常-上海财经大学.pptVIP

  • 4
  • 0
  • 约5.66千字
  • 约 24页
  • 2019-07-06 发布于天津
  • 举报
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精品文档

相关文档