Issues with basic_ostream
<p>I am getting this error when trying to compile my code:</p>

<pre><code>1&gt;  c:\mingw\bin\../lib/gcc/mingw32/4.6.2/include/c++/ostream: In constructor 'Log::Log(const char*)':
1&gt;c:\mingw\bin\..\lib\gcc\mingw32\4.6.2\include\c++\ostream(363,7): error : 'std::basic_ostream&lt;_CharT, _Traits&gt;::basic_ostream() [with _CharT = char, _Traits = std::char_traits&lt;char&gt;]' is protected
1&gt;C:\Users\Adam\Documents\cs\cs176b\hw2\ftp\ftp\log.cpp(6,26): error : within this context
</code></pre>

<p>Not really sure why, I didn't make the ostream code I am using myself, I used what was suggested here: <a href="http://stackoverflow.com/questions/14781629/proper-way-to-create-ostream-to-file-or-cout">Proper way to create ostream to file or cout</a></p>

<p>My code is below, happy to give any more info if needed:</p>

<pre><code>// log.h
#include &lt;string&gt;
#include &lt;fstream&gt;

#ifndef LOG_H_
#define LOG_H_

class Log 
{
    public:
        enum Mode { STDOUT, FILE };

        // Needed by default
        Log(const char *file = NULL);
        ~Log();

        // Writing methods
        void write(char *);
        void write(std::string);
    private:
        Mode mode;
        std::streambuf *buf;
        std::ofstream of;
        std::ostream out;
};

#endif


// log.cpp
#include "log.h"
#include &lt;iostream&gt;
#include &lt;stdlib.h&gt;
#include &lt;time.h&gt;

Log::Log(const char *file)
{
    if (file != NULL)
    {
        of.open(file);
        buf = of.rdbuf();
        mode = FILE;
    }
    else
    {
        buf = std::cout.rdbuf();
        mode = STDOUT;
    }

    // Attach to out
    out.rdbuf(buf);
}

Log::~Log()
{
    if (mode == FILE)
        of.close();
}

void Log::write(std::string s)
{
    out &lt;&lt; s &lt;&lt; std::endl;
}

void Log::write(char *s)
{
    out &lt;&lt; s &lt;&lt; std::endl;
}
</code></pre>
