C++ //练习 18.6 已知下面的异常类型和catch语句,书写一个throw表达式使其创建的异常对象能被这些catch语句捕获:
C++ Primer(第5版) 练习 18.6
练习 18.6 已知下面的异常类型和catch语句,书写一个throw表达式使其创建的异常对象能被这些catch语句捕获:
( a ) class exceptionType {};catch(exceptionType *pet) {}
( b ) catch(...) {}
( c ) typedef int EXCPTYPE;catch(EXCPTYPE) {}
环境:Linux Ubuntu(云服务器)
工具:vim
代码块
( a ) class exceptionType {};catch(exceptionType *pet) {throw new exceptionType();}
( b ) catch(...) {throw range_error;}
( c ) typedef int EXCPTYPE;catch(EXCPTYPE) {throw 1;}
