How can I use an fstream object as a member variable?
<p>Previously, I would pass the address of fstream objects to any functions, including the constructor, that do I/O operations. But I want to try making fstream objects available as member variables so that all subsequent I/O operations can use those variables instead of having them passed as arguments.</p>

<p>Consider the following Java program:</p>

<pre><code>public class A {
    Scanner sc;

    public A(Scanner read) {
        sc = read;
    }
}
</code></pre>

<p>What would be the C++ equivalent of this? I tried doing this</p>

<pre><code>class A {
    ofstream *out;

    public:
        A (ofstream &amp;output) {
            out = output;
        }
};
</code></pre>

<p>But this gives me a compilation error:</p>

<blockquote>
  <p>[Error] invalid user-defined conversion from 'std::ofstream {aka std::basic_ofstream}' to 'std::ofstream* {aka std::basic_ofstream*}' [-fpermissive]</p>
</blockquote>