title: Defining an output file stream within a class
body: <p>How can I define an output file stream within a class, so that I don't have to keep passing it around to functions. Basically what I want to do is this:</p>
  
  <pre><code>class A {
  
  private:
     ofstream otp ;
  
  };
  </code></pre>
  
  <p>Then in my constructor, I simply have <code>otp.open("myfile");</code> and in other functions I have <code>otp.open("myfile", ios::app);</code> , but it fails during compile time, saying:</p>
  
  <pre><code>../thermo.h(18): error: identifier "ofstream" is undefined
        ofstream otp ;
  </code></pre>
  
  <p>I have made sure to <code>#include &lt;fstream&gt;</code></p>
  
  <p>Thanks!</p>