Standard C++ Library Reference ISO/IEC (VERSION3)

basic_fstream
template <class Elem, class Tr = char_traits<Elem> >
class basic_fstream : public basic_iostream<Elem, Tr> {
public:
basic_fstream();
explicit basic_fstream(const char *filename,
ios_base::openmode mode =
ios_base::in | ios_base::out);
basic_filebuf<Elem, Tr> *rdbuf() const;
bool is_open() const;
void open(const char *filename,
ios_base::openmode mode =
ios_base::in | ios_base::out);
void close();
};
The template class describes an object that controls insertion and extraction of elements and
encoded objects using a stream buffer of class basic_filebuf<Elem, Tr>, with elements
of type Elem, whose character traits are determined by the class Tr. The object stores an object
of class basic_filebuf<Elem, Tr>.
basic_fstream::basic_fstream
basic_fstream();
explicit basic_fstream(const char *filename,
ios_base::openmode mode =
ios_base::in | ios_base::out);
The first constructor initializes the base class by calling basic_iostream(sb), where sb
is the stored object of class basic_filebuf<Elem, Tr>. It also initializes sb by calling
basic_filebuf<Elem, Tr>().
The second constructor initializes the base class by calling basic_iostream(sb). It also
initializes sb by calling basic_filebuf<Elem, Tr>(), then sb.open(filename,
mode). If the latter function returns a null pointer, the constructor calls
setstate(failbit).
basic_fstream::close
voidclose();
The member function calls rdbuf()-> close().