Standard Header Files
Header files of the C++ standard library
algorithm
|
ios
|
map
|
stack
|
bitset
|
iosfwd
|
memory
|
stdexcept
|
complex
|
iostream
|
new
|
streambuf
|
dequeue
|
istream
|
numeric
|
string
|
exception
|
iterator
|
ostream
|
typeinfo
|
fstream
|
limits
|
queue
|
utility
|
functional
|
list
|
set
|
valarray
|
iomanip
|
locale
|
sstream
|
vector
|
Note |
Some IDE's put the old-fashioned iostream.h and iomanip.h header
files at your disposal. Within these header files the identifiers of iostream and iomanip are not
contained in the std namespace but are declared
globally.
|
Header files of the C standard library
assert.h
|
limits.h
|
stdarg.h
|
time.h
|
ctype.h
|
locale.h
|
stddef.h
|
wchar.h
|
errno.h
|
math.h
|
stdio.h
|
wctype.h
|
float.h
|
setjmp.h
|
stdlib.h
|
|
iso646.h
|
signal.h
|
string.h
|
The C++ standard library header files are shown
opposite. They are not indicated by the file extension
.h and contain all the declarations in their own
namespace, std. Namespaces will be introduced in a
later chapter. For now, it is sufficient to know that identifiers from other
namespaces cannot be referred to directly. If you merely stipulate the
directive
Example:
#include <iostream>
the compiler would not be aware of the cin and cout streams. In order to
use the identifiers of the std namespace globally, you
must add a using directive.
Example:
#include <iostream> #include <string> using namespace std;
You can then use cin and cout without any additional syntax. The header file string has also been included. This makes the string class available and allows user-friendly string
manipulations in C++. The following pages contain further details on this
topic.
Header Files in the C Programming Language
The header files standardized for the C programming language
were adopted for the C++ standard and, thus, the complete functionality of the
standard C libraries is available to C++ programs.
Example:
#include <math.h>
Mathematical functions are made available by this statement.
The identifiers declared in C header files are globally visible.
This can cause name conflicts in large programs. For this reason each C header
file, for example name.h, is accompanied in C++ by a
second header file, cname, which declares the same
identifiers in the std namespace. Including the file
math.h is thus equivalent to
Example:
#include <cmath> using namespace std;
The string.h or cstring files must be included in programs that use standard
functions to manipulate C strings. These header files grant access to the
functionality of the C string library and are to be distinguished from the string header file that defines the string class.
Each compiler offers additional header files for platform
dependent functionalities. These may be graphics libraries or database
interfaces.
0 Comments