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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access