/* user-defined exception class derived from a standard class for exceptions*/
class MyProblem : public std::exception {
public:
...
MyProblem(...) { //special constructor
}
virtual const char* what() const throw() {
//what() function
...
}
};
...
void f() {
...
//create an exception object and throw it
throw MyProblem(...);
...
}
Run Code Online (Sandbox Code Playgroud)
我的问题是为什么在()之后有一个"const throw()"?通常,如果有一个throw(),它意味着throw()之前的函数可以抛出异常.但是,为什么抛出这里?