【发布时间】:2013-03-28 07:25:58
【问题描述】:
如果 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
【问题讨论】:
-
你尝试的时候得到了什么输出? :)