在下面的程序中,abort即使我有适用的catch语句,也会调用该方法.是什么原因?
#include <iostream>
#include <string>
using namespace std;
int main() {
try {
cout << "inside try\n";
throw "Text";
}
catch (string x) {
cout << "in catch" << x << endl;
}
cout << "Done with try-catch\n";
}
Run Code Online (Sandbox Code Playgroud)
当我运行程序时,我只inside try显示第一个语句,然后我收到此错误:

为什么abort即使在我处理string异常时也会被调用?
Lig*_*ica 14
真的很简单!
你扔了char const*,但没有匹配catch它.
你的意思是throw std::string("...");?
| 归档时间: |
|
| 查看次数: |
2857 次 |
| 最近记录: |