Overview of the Standard Library
The standard library has 51 headers, each containing a set of macro, function, type, and object declarations. A header is sometimes called a header file, but that phrase is misleading. An implementation does not need to implement headers as external files, although it is often simplest to think of a header as a file that contains macro, type, and function declarations.
Almost all the names declared in the standard library are in the
std
namespace. Macros, of course, are not in any namespace,
so it is important that you know which names are macros and which are
not. The detailed descriptions in Chapter
13 tell you this information. The only other names that are
outside the std
namespace are the
global operator
new
and operator
delete
functions, declared in the <new>
header.
To use the standard library, you must #include
the desired header or headers. Some implementations
#include
headers within other headers
(e.g., <set>
might #include <iterator>
). The headers that a
vendor includes within a header vary from one implementation to another,
so code that compiles successfully with one vendor’s environment might
not compile in a different environment. The solution is to get in the
habit of including all the headers you need.
Warning
If you see headers of the form <iostream.h>
, the program was probably written in the days before the C++ standard. It might ...
Get C++ In a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.