Opening a File for Input

Objects of class ifstream are opened for input by default, so the statement

ifstream inClientFile( "clients.txt" );

opens clients.txt for input. Just as with an ofstream object, an ifstream object can be created without opening a specific file, because a file can be attached to it later.

Get C++11 for Programmers, Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.