It's a well known fact that cout is unbuferred in VS2010 (see the post by Stephan Lavavej here). How come in the code below I can construct ostream hexout using cout's buffer ?
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
// Construct ostream hexout with cout's buffer and setup hexout to print hexadecimal numbers
ostream hexout(cout.rdbuf());
hexout.setf (ios::hex, ios::basefield);
hexout.setf (ios::showbase);
// Switch between decimal and hexadecimal output using the common buffer
hexout << "hexout: " << 32 << " ";
cout << "cout: " << 32 << " ";
hexout << "hexout: " << -1 << " " ;
cout << "cout: " << -1 << " ";
hexout << endl;
}