No offense, but do your own web search. The question is big enough that you are going to be better off reading a well written static web page with this info than us trying to recreate the info here in a short post. If you have a deeper question after reading that, then we can try to help.
The idea, as simply as I can express it, is that you sometimes want two classes to behave the same way or 'be the same thing' for a moment in your code.
All three output the bar. All three use the same operator.
All three: cout, ofs and gaz are all ostream objects.
Looks like a duck, sounds like a duck, ...
However, they are slightly different streams. The output goes to different destinations: standard output, file and string buffer, respectively.