Using the iostreams class
To declare the functions and external
data in the iostreams class, include the header file with the
statement
#include <iostream>
The first program uses the concept of
standard output, which means
“a general-purpose place to send output.” You will see other
examples using standard output in different ways, but here it will just go to
the console. The iostream package automatically defines a variable (an object)
called cout that accepts all data bound for
standard output.
To send data to standard output, you use
the operator <<. C programmers know this operator as the
“bitwise left shift,” which will be described in the next chapter.
Suffice it to say that a bitwise left shift has nothing to do with output.
However, C++ allows operators to be overloaded. When you overload an
operator, you give it a new
meaning when that operator is used with an object of a particular type. With
iostream objects, the operator << means “send to.” For
example:
cout << "howdy!";
sends the string “howdy!” to
the object called cout (which is short for
“console output”).
That’s enough operator overloading
to get you started. Chapter 12 covers operator overloading in
detail.