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. |