title: Output stream as class member
body: <p>I have a c++ library that provides an object with complicated logic. During data processing, this object outputs lots of things to std::cout (this is hardcoded now). I would like the processing output not to go to standard output but to a custm widget (some text displaying). I tried to create a <code>std::ostream</code> class member, set it with a parameter (std::cout for console application and some other ostream handled inside GUI application). But the compiler throws me following errors:</p>
  
  <pre>
  [ 14%] Building CXX object src/core/CMakeFiles/PietCore.dir/pvirtualmachine.cpp.o
  /usr/include/c++/4.6/ostream: In constructor ‘PVirtualMachine::PVirtualMachine(QString)’:                                                                        
  /usr/include/c++/4.6/ostream:363:7: error: ‘std::basic_ostream::basic_ostream() [with _CharT = char, _Traits = std::char_traits]’ is protected
  /home/tomasz/Development/C++/piet/src/core/pvirtualmachine.cpp:33:50: error: within this context
  In file included from /usr/include/c++/4.6/ios:45:0,
                   from /usr/include/c++/4.6/ostream:40,
                   from /usr/include/c++/4.6/iterator:64,
                   from /usr/include/qt4/QtCore/qlist.h:50,
                   from /usr/include/qt4/QtCore/qvector.h:48,
                   from /usr/include/qt4/QtGui/qpolygon.h:45,
                   from /usr/include/qt4/QtGui/qmatrix.h:45,
                   from /usr/include/qt4/QtGui/qtransform.h:44,
                   from /usr/include/qt4/QtGui/qimage.h:45,
                   from /usr/include/qt4/QtGui/QImage:1,
                   from /home/tomasz/Development/C++/piet/src/core/pcodepointer.h:17,
                   from /home/tomasz/Development/C++/piet/src/core/pblockmanager.h:9,
                   from /home/tomasz/Development/C++/piet/src/core/pvirtualmachine.h:10,
                   from /home/tomasz/Development/C++/piet/src/core/pvirtualmachine.cpp:4:
  /usr/include/c++/4.6/bits/ios_base.h: In member function ‘std::basic_ios& std::basic_ios::operator=(const std::basic_ios&)’:
  /usr/include/c++/4.6/bits/ios_base.h:791:5: error: ‘std::ios_base& std::ios_base::operator=(const std::ios_base&)’ is private
  /usr/include/c++/4.6/bits/basic_ios.h:64:11: error: within this context
  In file included from /usr/include/c++/4.6/iterator:64:0,
                   from /usr/include/qt4/QtCore/qlist.h:50,
                   from /usr/include/qt4/QtCore/qvector.h:48,
                   from /usr/include/qt4/QtGui/qpolygon.h:45,
                   from /usr/include/qt4/QtGui/qmatrix.h:45,
                   from /usr/include/qt4/QtGui/qtransform.h:44,
                   from /usr/include/qt4/QtGui/qimage.h:45,
                   from /usr/include/qt4/QtGui/QImage:1,
                   from /home/tomasz/Development/C++/piet/src/core/pcodepointer.h:17,
                   from /home/tomasz/Development/C++/piet/src/core/pblockmanager.h:9,
                   from /home/tomasz/Development/C++/piet/src/core/pvirtualmachine.h:10,
                   from /home/tomasz/Development/C++/piet/src/core/pvirtualmachine.cpp:4:
  /usr/include/c++/4.6/ostream: In member function ‘std::basic_ostream& std::basic_ostream::operator=(const std::basic_ostream&)’:
  /usr/include/c++/4.6/ostream:57:11: note: synthesized method ‘std::basic_ios& std::basic_ios::operator=(const std::basic_ios&)’ first required here 
  /home/tomasz/Development/C++/piet/src/core/pvirtualmachine.cpp: In member function ‘void PVirtualMachine::setOutput(std::ostream)’:
  /home/tomasz/Development/C++/piet/src/core/pvirtualmachine.cpp:216:11: note: synthesized method ‘std::basic_ostream& std::basic_ostream::operator=(const std::basic_ostream&)’ first required here
  </pre>
  
  <p>I'd be glad if someone pointed me out what is wrong, because I've got no idea...</p>
  
  <p>My code looks like this:</p>
  
  <ul>
  <li>.h file</li>
  </ul>
  
  <pre>
  class PVirtualMachine {
    private:
      std::ostream output;
      [...]
    public:
      void setOutput(std::ostream);
      [...]
  };
  </pre>
  
  <ul>
  <li>.cpp file</li>
  </ul>
  
  <pre>
  void PVirtualMachine::setOutput(std::ostream os)
  {
    output = os;
  }
  </pre>