How can I derive a class from cout so that, for example, writing to it
cout
new_cout << \"message\";
would be equivalent to
You could also override the operator. It will allow you to call another function or prefix/suffix anything that's going to leave the output buffer with whatever you wish: In your case, you'd have it output a specific string.