tailieunhanh - Module 11 The C++ I/O System

The most fundamental point to understand about the C++ I/O system is that it operates on streams. A stream is an abstraction that either produces or consumes information. A stream is linked to a physical device by the C++ I/O system. All streams behave in the same manner, even if the actual physical devices they are linked to differ. Because all streams act the same, the same I/O functions and operators can operate on virtually any type of device. For example, the same method that you use to write to the screen can be used to write to a disk. | Module 11 The C I O System Table of Contents CRITICAL SKILL Understand I O CRITICAL SKILL Know the I O class CRITICAL SKILL Overload the and CRITICAL SKILL Format I O by using iso member CRITICAL SKILL Format I O by using CRITICAL SKILL Create your own CRITICAL SKILL Open and close CRITICAL SKILL Read and write text CRITICAL SKILL Read and write binary CRITICAL SKILL Know additional file CRITICAL SKILL Use randon access files I CRITICAL SKILL Check I O system Since the beginning of this book you have been using the C I O system but you have been doing so without much formal explanation. Since the I O system is based upon a hierarchy of classes it was not possible to present its theory and details without first discussing classes and inheritance. Now it is time to examine the C I O system in detail. The C I O system is quite large and it won t be possible to discuss here every class function or feature but this module will introduce you to the most important and commonly used parts. Specifically it shows how to overload the and operators so that you can input or output objects of classes that you design. It describes how to format output and how to use I O manipulators. The module ends by discussing file I O. Old vs. Modern C I O There are currently two versions of the C object-oriented I O library in use the older one that is based upon the original specifications for C and the newer one defined by Standard C . The old I O library is supported by the header file . The new I O library is supported by the header 1 C A Beginner s Guide by Herbert Schildt iostream . For the most part the two libraries appear the same to the programmer. This is because the new I O library is in essence simply an updated and improved version of the old one. In fact the vast majority

TỪ KHÓA LIÊN QUAN