The std::
before cout
is required when we use names that we’ve brought into the program by the preprocessing directive #include <iostream>
. The notation std::cout
specifies that we are using a name, in this case cout
, that belongs to namespace std
. The names cin
(the standard input stream) and cerr
(the standard error stream)—introduced in Chapter 1—also belong to namespace std
. Namespaces are an advanced C++ feature that we discuss in depth in Chapter 21, Other Topics. For now, you should simply remember to include std::
before each mention of cout
, cin
and cerr
in a program. This can be cumbersome—the next example introduces using
declarations and the using
directive, which will enable you to omit std::
before each use of a name in the std
namespace.