当我的C++方法遇到一些奇怪的东西并且不能恢复时,我想抛出一个异常。可以抛出一个std::string
指针吗?
这是我期待做的事情:
void Foo::Bar() {
if(!QueryPerformanceTimer(&m_baz)) {
throw new std::string("it's the end of the world!");
}
}
void Foo::Caller() {
try {
this->Bar(); // should throw
}
catch(std::string *caught) { // not quite sure the syntax is OK here...
std::cout << "Got " << caught << std::endl;
}
}
https://stackoverflow.com/questions/134569
复制相似问题