Using stream classes

You can print floating point numbers and integers to the console using the cout object (an instance of the ostream class) or to files with an instance of ofstream. Both of these classes will convert numbers to strings using member methods and manipulators to affect the formatting of the output string. Similarly, the cin object (an instance of the istream class) and the ifstream class can read data from formatted streams.

Manipulators are functions that take a reference to a stream object and return that reference. The Standard Library has various global insertion operators whose parameters are a reference to a stream object and a function pointer. The appropriate insertion operator will call the function pointer with ...

Get Beginning C++ Programming 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.