basic_fstream::basic_fstream
Constructs an object of type basic_fstream.
basic_fstream( );
explicit basic_fstream(
const char *_Filename,
ios_base::openmode _Mode = ios_base::in | ios_base::out,
int _Prot = (int)ios_base::_Openprot
);
explicit basic_fstream(
const wchar_t *_Filename,
ios_base::openmode _Mode = ios_base::in | ios_base::out,
int _Prot = (int)ios_base::_Openprot
);
basic_fstream(basic_fstream&& right);
Parameters
_Filename
The name of the file to open._Mode
One of the enumerations in ios_base::openmode._Prot
The default file opening protection, equivalent to the shflag parameter in _fsopen, _wfsopen.
Remarks
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 and third constructors initializes the base class by calling basic_iostream(sb). It also initializes sb by calling basic_filebuf<Elem, Tr>, and then sb.open(_Filename, _Mode). If the latter function returns a null pointer, the constructor calls setstate(failbit).
The fourth constructor initializes the object with the contents of right, treated as an rvalue reference.
Example
See streampos for an example that uses basic_fstream.
Requirements
Header: <fstream>
Namespace: std