
13 Jan
2005
13 Jan
'05
4:49 p.m.
christopher diggins wrote:
This is just a reflection of the general "globals are bad" principle.
Most of the application code I have seen written, does so directly to cout rather than to a function parameter. I also don't see any advantage to passing istream and ostream as function parameters, when cin and cout can be easily redirected using rdbuf.
The advantages of following a style of programming where functions do not take hidden arguments and do not reference global state are well known. Even if in this particular case the "wrong way" does not cause much harm because of cin and cout's redirection capability, in general, if a module has been written to operate on a hardcoded global (or a singleton), you will not be able to reuse it.