In the previous lesson, this was touched on with an example that used cout. Here we'll go into a bit more depth starting with output first as it tends to be more used than input.
The iostream class provides access to the objects and methods you need for both output and input. Think of i/o in terms of streams of bytes- either going from your application to a file, the screen or a printer - that's output, or from the keyboard - that's input.
Output with cout
If you know C, you may know that << is used to shift bits to the left. Eg 3 << 3 is 24. Eg left shift doubles the value so 3 left shifts multiplies it by 8.In C++, << has been overloaded in the ostream class so that int, float, and strings types (and their variants- eg doubles) are all supported. This is how you do text output, by stringing together multiple items between <<.
cout << "Some Text" << intvalue << floatdouble << endl;
This peculiar syntax is possible because each of the << is actually a function call which returns a reference to an ostream object. So a line like the above is actually like this
cout.<<("some text").cout.<<( intvalue ).cout.<<(floatdouble).cout.<<(endl) ;The C function printf was able to format output using Format Specifiers such as %d. In C++ cout can also format output but uses a different way of doing it.
On the next page - Formatting with Cout.

