title: how to temporarily use std::cout in place of std::ofstream
body: <p>if I want to create a logging class, say</p>
  <pre><code>class logging_class {
  public:
      std::ofstream error;
      std::ofstream event;
      logging_class() {}
      logging_class(string err, string evt) {
          error.open(err);
          event.open(evt);
      }
      ~logging_class() {
          error.close();
          event.close();
      }
  };
  </code></pre>
  <p>so that later I can easily create program log:</p>
  <pre><code>logging_class logger(&quot;Log_Error.txt&quot;,&quot;Log_Event.txt&quot;);
  logger.error &lt;&lt; &quot;something wrong&quot;;
  logger.event &lt;&lt; &quot;something interesting&quot;;
  </code></pre>
  <p>Now, at the early stage of development, I want to redirect all the output to screen (i.e. std::cout). I don't want to change the usage of <code>logger.error&lt;&lt;&quot;something wrong&quot;;</code> to <code>std::cout&lt;&lt;&quot;something wrong&quot;;</code>, because later I will need to change all instances of <code>std::cout</code> to either <code>logger.error</code> or <code>logger.event</code> (maybe thousands of them). Can I make some easy changes in the class logger to do this?</p>
  <p>Update: Following Enlico's instruction, I can modify the <code>logging_class</code> as:</p>
  <pre><code>class logging_class {
  public:
      //std::ofstream error;
      //std::ofstream event;
      std::ostream&amp; error;
      std::ostream&amp; event;
      logging_class():error(std::cout),event(std::cout) {}
      //logging_class(string err, string evt) {
      //    error.open(err);
      //    event.open(evt);
      //}
      //~logging_class() {
      //    error.close();
      //    event.close();
      //}
  };
  </code></pre>
  <p>and after creating object with default constructor:
  <code>logging_class logger;</code>
  I can now redirect all the logging to screen display.</p>