我目前正在处理我自己的继承的异常类,std::exception
我不确定我是应该创建自己的,what()
还是只调用
std::exception("message")
我的类构造函数.这是我目前的代码:
FilterException::FilterException(const char* message, int num) noexcept :
error_message(message), error_number(num) {}
const char* FilterException::what() const noexcept
{
return error_message.c_str();
}
FilterException::~FilterException() noexcept
{
}
int FilterException::getErrorNumber() const noexcept
{
return error_number;
}
Run Code Online (Sandbox Code Playgroud)
所以,我的问题,我应该像这样离开它,还是在构造函数中做出改变并摆脱what()
?
我很难理解为什么这个代码会导致3f000000
.
float f = 5e-1;
printf("%x", *(int*)&f);
Run Code Online (Sandbox Code Playgroud)