I'm curious about why I output by different ostream, and don't flush them, but when program exited, they won't mess up the order, does an ostream flush others stream?how C++ standard library make they communicate?
#include <iostream>
int main()
{
std::clog << "flush test1 by clog\n";
std::cout << "flush test1 by cout\n";
std::cout << "flush test2 by cout\n";
std::clog << "flush test2 by clog\n";
return 0;
}
/* The output is
* flush test1 by clog
* flush test1 by cout
* flush test2 by cout
* flush test2 by clog
*/