4

Possible Duplicate:
How can I compose output streams, so output goes multiple places at once?

In 0-th approximation I have a class

class MyClass{
public:
   ...
   std::ostream & getOStream(){return f;}
private:
   ofstream f;
   ...
};

Which is used sometimes in the following way:

MyClass myclass;
myclass.getOStream()<<some<<information<<printed<<here;

But now I want to change the class MyClass, so that information will be printed both to f and to std::out, i.e. I want the above line to be equivalent to

myclass.f<<some<<information<<printed<<here;
std::cout<<some<<information<<printed<<here;

I don't know any good way to do that. Do you? Is there any standard solution (for example in stl or in boost)?

P.S. I tried to search on this, but it seems that I don't know good keywords. Words multiple, output, ostream, C++, boost seem to be too general.

Community
  • 1
  • 1
fiktor
  • 1,303
  • 2
  • 11
  • 22
  • You could write your own ostream class but the problem with that is you need to write it. –  Nov 22 '11 at 01:43

0 Answers0