Chapter 23

Using Stream I/O

In This Chapter

arrow Performing input/output

arrow Rediscovering stream I/O as an overloaded operator

arrow Examining the other methods of the file class

arrow Using stream buffer I/O

Programs appearing before this chapter read from the cin input object and output through the cout output object. Perhaps you haven't really thought about it much, but this input/output technique is a subset of what is known as stream I/O.

In this chapter, I describe stream I/O in more detail. I must warn you that stream I/O is too large a topic to be covered completely in a single chapter — entire books are devoted to this one topic. Fortunately for both of us, there isn’t all that much that you need to know about stream I/O to write the vast majority of programs.

How Stream I/O Works

Stream I/O is based on overloaded versions of operator>>() and operator<<(). The declaration of these overloaded operators is found in the include file iostream, which are included in all the programs in this book beginning with Chapter 1. The code for these functions is included in the standard library, which your ...

Get C++ For Dummies, 7th 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.