【发布时间】:2015-02-08 20:44:36
【问题描述】:
有人能解释为什么自写的 C++ 异常,继承自异常返回一个 char * 而不是一个字符串?
class myexception: public exception
{
virtual const char* what() const throw()
{
return "My exception happened";
}
} myex;
【问题讨论】:
-
覆盖
std::exception的what()。
标签: c++ string pointers exception char