Console C++ - iostream Template Namespace

iostream is supposed to be the operating system independent way to read and write data.

In general, this works pretty good if you include iostream.h. However, if you use the new standard template

there is a major difference. According to the 1998 C++ standard, when any of the new C++ Standard Library classes are used (such as <iostream>), the following command is required in order to actually use the applicable commands. However, in Borland C++ 5.02, it does not work. (It was fixed in version 5.5.) For a work around so that your code will work with other compilers, Microsoft vs. Borland Portability Woes presents Another solution (workaround) is to add a line which defines (or extends) the std namespace before your using statement.

Alternate Syntax

Well the kludges above worked ok until the teacher required the following constructs. I couldn't find any simple way to handle this. The following is my best suggestion. I know I could have defined an alias (macro) for std:: and used that to reduce the number of if statements. However, I don't think that that would be as clear for a beginning course.

Author: Robert Clemenzi -
URL: http:// / user / clemenzi / technical / Languages / Console_C++ / iostream.html