当抛出异常时,尝试用cout语句阻塞行为
Try block behavior with cout statements when an exception is thrown
如果在try块中抛出异常之前包含cout语句,这些语句会被打印到控制台,还是会表现得好像try块从未执行过?例如:
void foo()
{
try
{
cout << "1" << endl;
cout << "2" << endl;
bar(); //exception thrown in this function, but caught below
}
catch (exception e)
{
cout << e.what(); //assume the message is "error"
}
}
这个函数的输出是否为
1
2
error
或
error
输出为
1
2
error
异常不会"撤消"
的效果cout << "1" << endl;
cout << "2" << endl;
相关文章:
- 在 COUT 语句中使用 COUT 调用函数
- C++程序在一定行后未正确编译[cout语句]
- 这种递归是如何到达 COUT 语句的?
- 0x%08lx 格式说明符在 printf 语句到 cout
- 我收到一个断言错误,但是当我编写 cout 语句时,它会消失
- 一个语句中没有多个 cout 的错误/警告
- 为什么 cout 语句在传递指向函数的指针时没有执行?
- 两个 cin / cout 语句合并为一个
- 在 cout 语句中首先运行什么?(C++17)
- if 语句仅在前面有调试 cout 行(C 中的多线程)时才通过
- 使用自定义宏来简化 cin 和 cout 语句等内容被认为是更好还是更差
- 单个cout中的多个语句产生不同的结果
- 尽管我的功能和cout语句的放置错误,但我的程序为什么会起作用
- 如何在COUT语句中使用移动运算符
- 如果语句在第一次尝试后没有给出 cout
- C :Bool方法在COUT语句之后返回意外数字
- cout 输出乱码消息行,而不是实际用户的 cout 语句
- 添加 cout 语句会更正输出
- 如何仅使用循环/控制语句和两个cout语句创建一个倒三角:一个输出“#”和一个输出' n'
- 为什么语句"cout << '\\\\';"没有失败?