well, it can be done... if you're writing the operating system and it's compilers, but that's probably not the answer you wanted...
Since we're near the subject, I felt like writing an example as to how stream redirection can cut down on code by alot--especially when you need to write things to two files or print things to the screen and write them to a file.
Code:
#include <iostream>
#include <fstream>
void print(std::ostream&out,const char*data);
int main()
{
std::fstream file("test.dat",std::ios::out|std::ios::trunc);
print(file,"Hello World\n");
print(std::cout,"dlorW olleH\n");
file.close();
return 0;
}
void print(std::ostream&out,const char*data)
{
out<<data;
}
of course, like this it won't be very useful, but if you rewrote the function to always output to everything you need, it just takes one function call to output to every target.