title: How to derive from C++ std::basic_ostream and make the << operator virtual?
body: <p>I am writing a class that has various messages output. I want to make this class general and platform independent, so I am thinking of passing a <strong>basic_ostream</strong> reference to it and it can dump all the messages into the stream. By doing this, if the class is used in a console program, I can pass <strong>std::cout</strong> to it and display in console window. </p>
  
  <p>Or I could pass a derived ostream to it and redirect the message to some UI components, e.g. ListBox? The only problem is the data inserter <code>operator &lt;&lt;</code> is not a virtual function. If I pass the derived class reference to it, only the <strong>basic_ostream</strong> &lt;&lt; operator will be called. </p>
  
  <p>Is there any workaround for this?</p>