Chapter Summary


C++ uses library classes to handle input and output:

  • The iostream classes handle stream-oriented input and output

  • The fstream classes handle IO to named files

  • The stringstream classes do IO to in-memory strings

All of these classes are related by inheritance. The input classes inherit from istream and the output classes from ostream. Thus, operations that can be performed on an istream object can also be performed on either an ifstream or an istringstream. Similarly for the output classes, which inherit from ostream.

Each IO object maintains a set of condition states that indicate whether IO can be done through this object. If an error is encounteredsuch as hitting end-of-file on an input streamthen the object's state will be such that no further input can be done until the error is rectified. The library provides a set of functions to set and test these states.



C++ Primer
C Primer Plus (5th Edition)
ISBN: 0672326965
EAN: 2147483647
Year: 2006
Pages: 223
Authors: Stephen Prata

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net