TITLE: outputting to two streams (Source: comp.lang.c++, 17 Nov 2000) JACQUES: jacques (innocence@waveform.org) : i have a function which needs to either send various bits of text output : to std::cout or to a std::ofstream. is there any elegant way around the : following? : : if (use_file) : my_text_file << "xxxxxxxx"; : else : std::cout << "xxxxxxxx"; KUEHL: Dietmar Kuehl std::ostream out(use_file? my_text_file.rdbuf(): std::cout.rdbuf()); out << "xxxxxxxxxx"; The other suggestions I have seen are kind of lame... _______________________________________________ cpptips mailing list http://cpptips.hyperformix.com