【发布时间】:2010-10-04 16:07:46
【问题描述】:
/* 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(...);
...
}
我的问题是为什么在 what() 之后有一个“const throw()”? 通常,如果有 throw() ,则表示 throw() 之前的函数 可以抛出异常。但是,为什么这里会抛出异常呢?
【问题讨论】: