EXPLORATION 5

image

Simple Input

So far, the Explorations have focused on output. Now it’s time to turn your attention to input. Given that the output operator is <<, what do you expect the input operator to be? ________________

That didn’t take a rocket scientist to deduce, did it? The input operator is >>, the opposite direction of the output operator. Think of the operators as arrows pointing in the direction that information flows: from the stream to variables for input, or from variables to the stream for output.

Listing 5-1 shows a simple program that performs input and output.

Listing 5-1.  Demonstrating Input and Output

#include <iostream> ...

Get Exploring C++ 11, Second Edition 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.