[Home]  [Edit this page]  [Recent Changes]  [Special Pages]  [Help
CppStream

(C++) Streams

Stream Classes

A  ?stream is a general name given to a flow of data. A stream is represented by an object of a particular class. Different streams are used to represent different kinds of data flow.

Advantages of Streams

C programmers may wonder what advantages there are to using the stream classes for i/o instead of traditional C functions such as printf() and scanf() and, for files, fprintf() and fscanf() and so on. There are no formatting special characters like %d and %f in streams since each object already knows how to display itself. In C++, streams are the best to write data to files and also to format data in memory for later use in text i/o windows and other GUI elements.

Stream Class Hierachy

The extraction operator >> is a  ?member of the  ?std::istream class and the insertion operator << is a member of the  ?std::ostream class. Both of these classes are derived from the ios class. The std::cout object representing the standard output stream, which is usually directed to the video display, is a predefined object of the ostream_withassign class, which is derived from the ostream class. Similarly, std::cin is an object of the istream_with assign class which is  ?derived from  ?std::istream.

You can  ?overload the stream in operator and overload the stream out operator.

Also, you can manipulate streams.



last edited (December 24, 2006) by bilderbikkel, Number of views: 1242, Current Rev: 2 (Diff)

[Edit this page]  [Page history]  [What links here]  [Discuss this topic]  [Printer Friendly]  

Members

Username:

Password:


Register
Forgot Password?




Programmers Heaven - for .NET, Java, C/C++ and WEB Developers!
© 1996-2008 Community Networks Ltd. All rights reserved. Reproduction in whole or in part, in any form or medium without express written permission is prohibited. Violators of this policy may be subject to legal action. Please read Terms Of Use and Privacy Statement for more information. Development by Tore Nestenius at .NET Consultant - Synchron Data.