Originally posted here by progme


No, cout will always display to the console window, you may be confused with ostream. The difference between cout and ostream is cout is an object while ostream is a type. The ostream type can be used on any particular device while the cout object is initialized to be used for the console.
Of course ostream is a type, otherwise you wouldn't be able to create an instance of it. Don't think that I'm confused between the two.

std::cout will print to standard output, just like std::cin will read from standard input. What those happen to refer to are not necessarily the console, although as I stated before 90% of the time they are (and they will most likely be so for the majority of simple programs). As a programmer, it's not just important to realise what *you* have control over, but also what the user may choose to do with your program. For example, if the hello world program was run as:

Code:
./hello > hello.txt
under *nix, then the output would not go to the console because it is redirected. That doesn't mean that the programmer can control where std::cout goes (because it is sent to the standard output - wherever that may be set to), but s/he should be aware of the fact that it may be redirected by the user.

So, in conclusion, cout will not always display to the console window, even if that happens to be the default.