can i pass std::ostream& to a function expecting std::ofstream
<p>What i'm trying to do is:
I want to redirect my error message erither to std::cerr or to a file
depending upon the <code>command-line</code> argument. If there is no log file provided then the program should output the error message on screen.
Here is my approach:</p>

<pre><code>class A {

    void SetLogFileStream(T&amp; err_outstream);
};
</code></pre>

<p>//main.cpp</p>

<pre><code>A a;
std::string filename;
T1* t1;
if(argc&gt;2) {
    filename = argv[1]; //if provided by command line 

    std::ofstream fp(filename);
    t1 = &amp;fp;

}
else {

    std::ostream* err_outstream = &amp;std::cerr;
    t1 = err_outstream;
}

a.SetLogFileStream(t1);
</code></pre>

<p>what should be the argument type of the function <code>SetLogFileStream</code> 
or the type <code>T1</code>
so that i can pass a pointer either to file or to  <code>std::cerr</code></p>
