C++ Demystified(c) A Self-Teaching Guide
-
Data is persistent when it survives after the program is finished.
-
A file is a collection of data that is located on persistent storage, such as a hard drive, a CD-ROM, or other storage device.
-
Files store data in either text or binary format.
-
You should include the fstream standard library when your program reads from, or writes to, files.
-
The fstream object may be used both for file input and file output.
-
You can open a file with either the open member function or a constructor.
-
The purpose of opening a file is to establish a path of communication between the file and a file stream object in your program.
-
The purpose of closing a file is to free system resources that are required to maintain the path of communication between the file and the file stream object in your program.
-
A constructor is a function that is automatically called when you attempt to create an instance of an object.
-
The fail member function is a better choice than the eof member function for detecting end of file in a text file.
-
File stream objects should be passed as function arguments by reference rather than by value.
Категории