Files such as iostream
are called include files (because they are included in other files) or header files (because they are included at the beginning of a file). C++ compilers come with many header files, each supporting a particular family of facilities. The C tradition has been to use the h
extension with header files as a simple way to identify the type of file by its name. For example, the C math.h
header file supports various C math functions. Initially, C++ did the same. For instance, the header file supporting input and output was named iostream.h
. But C++ usage has changed. Now the h
extension is reserved for the old C header files (which C++ programs can still use), whereas C++ header files have no extension. There are also C header files that have been converted to C++ header files. These files have been renamed by dropping the h
extension (making it a C++-style name) and prefixing the filename with a c
(indicating that it comes from C). For example, the C++ version of math.h
is the cmath
header file. Sometimes the C and C++ versions of C header files are identical, whereas in other cases the new version might have a few changes. For purely C++ header files such as iostream
, dropping the h
is more than a cosmetic change, for the h
-free header files also incorporate namespaces, the next topic in this chapter. Table 2.1 summarizes the naming conventions for header files.
In view of the C tradition of using different filename extensions to indicate different file types, it appears reasonable to have some special extension, such as .hpp
or .hxx
, to indicate C++ header files. The ANSI/ISO committee felt so, too. The problem was agreeing on which extension to use, so eventually they agreed on nothing.
3.133.158.36