#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";}
当我运行程序时,我只在try里面显示第一个语句,然后我收到此错误:
为什么即使在我处理字符串异常时也会调用abort?
解决方法 真的很简单!你扔了char const *,但没有匹配的catch.
你的意思是抛出std :: string(“…”);?
总结以上是内存溢出为你收集整理的c – 为什么要调用中止方法?全部内容,希望文章能够帮你解决c – 为什么要调用中止方法?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)