Opening a File via the open Member Function

You can create an ofstream object without opening a specific file—in this case, a file can be attached to the object later. For example, the statement

ofstream outClientFile;

creates an ofstream object that’s not yet associated with a file. The ofstream member function open opens a file and attaches it to an existing ofstream object as follows:

outClientFile.open( "clients.txt", ios::out );


Image Error-Prevention Tip 14.2

Some operating systems allow you to open the same file multiple times simultaneously. Avoid doing this because it can lead to subtle problems.


..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset