Q: What are traditional C++ (pre-standard) headers?
A: The traditional C++ (pre-standard) headers define classes, values, macros, and functions in headers that have *.h extension. This includes non-standard STL headers with *.h extension (iostream.h, fstream.h, vector.h, etc.) and C headers with *.h extension (stdlib.h, stdio.h, etc.). Pre-standard headers have all the code in the global namespace.
Q: What are C++ standard headers?
A: C++ standard headers are those headers that are specified by the C++ standard.
Q: How do I recognize the C++ standard headers?
A: The naming scheme for these files were specified based on the naming scheme of the traditional header files, but without the ending '.h'. For example, 'fstream.h' becomes 'fstream', 'memory.h' becomes 'memory' and so on.
Q: What about 'iostream.h'?
A: The header iostream.h has never been part of the official C++ standard, which means any compiler that provides iostream.h, can do what ever it wants with it, and the compiler would still be considered compliant with the C++ standard. However, the C+ standard specifies the existence of a header within the input/output library.
Q: What about the traditional ANSI C standard header files?
A: The traditional ANSI C standard header files are prefixed with the letter 'c'. Thus 'stdio.h' has become 'cstdio', 'stdlib.h' is called 'cstdlib', 'math.h' is called 'cmath', 'time.h' is called 'ctime' and so on. This is the complete list:
Formatting and manipulators: <istream>, <ostream>, <iomanip>
String streams: <sstream>, <cstdlib>
File streams: <fstream>, <cstdio>, <cwchar>
Q: Could I still use the extension version of the C headers (stdlib.h, stdio.h, etc.)?
A: All compliant C++ compilers support the 18 deprecated C header files with the *.h extension (stdlib.h, stdio.h, etc.). The *.h extension C header files are in the global namespace. Code using the extension version of the C headers is still considered portable, but it might not be portable with a future version of the standard. However, itís unlikely that these headers will ever be completely removed from the official standard.
Q: Could I still use the non-standard *.h extension version of the STL headers (iostream.h, fstream.h, vector.h, etc.)?
A: The extension versions of the STL headers have never been part of the official C++ standard. Most compilers support the non-standard STL headers, and some obsolete compilers (like Turbo C++) only support the non-standard version of the STL headers. More modern compliant compilers like VC++ 7.1, do not support these files at all. Unless an obsolete compiler is being used, all new code should be developed using the extension-less version of the STL headers (<iostream>, <fstream>, <vector>, etc.). Code using *.h extension version of the STL headers is not considered portable.
Credits: This FAQ is the result of a joint effort of Cilu, Andreas Masur and Axter.
Last edited by cilu; September 17th, 2005 at 09:10 AM.
On certain compilers, for example, you may find 'iostream' as well as 'iostream.h'. As pointed out above including 'iostream' keeps the members in the std namespace whereas usage of 'iostream.h' adds up the members into the global namespace. This may lead to ambiguities that the namespaces were designed to avoid. This is another small reason in addition to others mentioned above for not including the '.h' extension headers.
Last edited by Andreas Masur; September 4th, 2005 at 10:29 AM.