All the afford needed to create a new stream class was to override the methods sync and overflow of basic_streambuf and write implementations for the output routines. Now we can write to a console window from a GUI based application:
OG_constream text_fenster;
int i = 10;
double d = 3.14156;
std::string sstr("STL String");
CString cstr("Microsoft CString");
text_fenster << "i = " << i << std::endl;
text_fenster << "d = " << d << std::endl;
text_fenster << "STL String = " << sstr.c_str() << std::endl;
text_fenster << "Microsoft CString = " << (LPCSTR) cstr << std::endl;