因为异常这个知识点好久没用,有点忘记了(我初学),打算给之前写的东西弄个自定义异常,练习一下就当复习了
class Treeexception : public exception {
string error_str;
public:
Treeexception(const char* ex){
error_str = ex;
}
Treeexception(string ex){
error_str = ex;
}
const char* what() const throw(){
return this->error_str.c_str();
}
virtual ~Treeexception(){}
};
打算测试一下
void func() throw(Treeexception) {
throw Treeexception("test !");
}
然后 报错 :