A.2. IOStream Overview
In “Type-Safe I/O” on page 55, you learned the basics for performing input (extraction) and output (insertion). The insertion operator (<<) inserts bytes into an output stream, such as cout (standard output) or cerr (standard error). Similarly, the extraction operator (>>) extracts bytes from an input stream, such as cin (standard input). The task of the IOStream library is to convert streams of bytes from an input stream into data that is consistent with its argument type. The IOStream library also converts the binary representation of a data value into bytes for an output stream. Thus, if i is an integer, the statement
cin >> i;
converts bytes from istream cin into an integer value. Likewise, the statement
cout << ...
Get Navigating C++ and Object-Oriented Design 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.