Name
basic_ifstream class template — Class template for file input streams
Synopsis
template <class charT, class traits = char_traits<charT> > class basic_ifstream : public basic_istream<charT,traits> { public: typedef charT char_type; typedef typename traits::int_type int_type; typedef typename traits::pos_type pos_type; typedef typename traits::off_type off_type; typedef traits traits_type; basic_ifstream( ); explicit basic_ifstream(const char* s, ios_base::openmode mode = ios_base::in); basic_filebuf<charT,traits>* rdbuf( ) const; bool is_open( ); void open(const char* s, ios_base::openmode mode = ios_base::in); void open(const char* s, ios_base::open_mode mode); void close( ); };
The basic_ifstream class
template supports reading from named files using a basic_filebuf<charT, traits> object. (See <istream> for a description of the
base-class template, basic_istream.) In the following member
function descriptions, the file buffer object is assumed to be a
private data member with the name
buf:
-
basic_ifstream( ) Initializes the base class with
basic_istream(&buf)and initializesbufwith its default constructor.explicitbasic_ifstream(constchar*filename, ios_base::openmodemode=ios_base::in)Initializes the base class and
buf, then callsopen(filename,mode). Ifopenreturns a null pointer, the constructor callssetstate(failbit).basic_filebuf<charT,traits>*rdbuf( )constReturns
&buf.boolis_open( )Returns
rdbuf( )->is_open( ).voidopen(constchar*filename, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access