c++ - Try block behavior with cout statements when an exception is thrown -
if try block contains cout statements before exception thrown in same block, statements printed console, or behave if try block never executed? example:
void foo() { try { cout << "1" << endl; cout << "2" << endl; bar(); //exception thrown in function, caught below } catch (exception e) { cout << e.what(); //assume message "error" } } would output of function be
1 2 error or
error
the output
1 2 error the exception not "undo" effects of
cout << "1" << endl; cout << "2" << endl;
Comments
Post a Comment