Home arrow C++ arrow Page 4 - Introduction to Streams

Introduction to Streams

C++, unlike C, has the kinds of services and additions that, at the beginning at least, seem like evil dinosaurs meant to make your life harder and to complicate simple problems. However, once you get the hang of them, you’ll realize the opportunities that they give you, and you won’t ever want to use the older C methods for the same purpose again. Streams are one of these wicked dinosaurs.

Author Info:
By: Gabor Bernat
Rating: 5 stars5 stars5 stars5 stars5 stars / 8
March 17, 2009
  1. · Introduction to Streams
  2. · Abstract Representation
  3. · How Should They Look?
  4. · Conclusion

print this article

Introduction to Streams - Conclusion
(Page 4 of 4 )

Another motivation for using the streams instead of the old stdio library is that there is a good chance that this improves readability and performance. Despite the fact that these are also streams, we won’t cover them; instead, we will focus on the more stylish usage of the iostream class family.

In conclusion the definition taken from the MSDN library sums up all that we have said until now: “You can think of a stream object as a smart file that acts as a source and destination for bytes. A stream's characteristics are determined by its class and by customized insertion and extraction operators.”

C usually associates three file descriptors with an application: stdin (standard input), stdout (standard output), stderr (standard error). Despite the fact that these are mapped to devices like the keyboard and monitor, they are represented in files, showing that C was designed initially for UNIX, where every input/output is treated as a file. The iostream classes (where all the streams are defined) are an object-oriented I/O alternative to the C run-time functions.

The older file input/output has been replaced by the stream classes, as I’ll also cover in a future article. Generally speaking, it is a good idea to use streams every time you can, instead of the old C library, which is still active and usable under the C++ language.

And now the bell rings and we suspend this class on insights into streams for today, but you can freely ask your questions in the blog comments that follow the article -- or join our friendly ever-growing forums over at DevHardware and enjoy the full benefits of being a regular member. Until we meet again (remember to keep your eyes open since the entire series will be published here!) take care and… “Live with Passion!”

DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

blog comments powered by Disqus

- Intel Threading Building Blocks
- Threading Building Blocks with C++
- Video Memory Programming in Text Mode
- More Tricks to Gain Speed in Programming Con...
- Easy and Efficient Programming for Contests
- Preparing For Programming Contests
- Programming Contests: Why Bother?
- Polymorphism in C++
- Overview of Virtual Functions
- Inheritance in C++
- Extending the Basic Streams in C++
- Using Stringstreams in C++
- Custom Stream Manipulation in C++
- General Stream Manipulation in C++
- Serialize Your Class into Streams in C++

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 

Developer Shed Affiliates


© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials