8.2.1. Using File Stream Objects
When we want to read or write a file, we define a file stream object and associate that object with the file. Each file stream class defines a member function named open
that does whatever system-specific operations are required to locate the given file and open it for reading or writing as appropriate.
When we create a file stream, we can (optionally) provide a file name. When we supply a file name, open
is called automatically:
ifstream in(ifile); // construct an ifstream and open the given fileofstream out; // output file stream that is not associated with any file
This code defines in
as an input stream ...
Get C++ Primer, Fifth Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.