ifstream::ifstream (const
char* fname [,
int mode [,
int prot]])
Constructor
By default, the file is opened for input (with ios::in as mode).
If you use this constructor,
the file will be closed when the ifstream
is destroyed. You can use the following
optional arguments for mode
to specify how to open the file, by combining these enumerated values (with
bitwise or, ‘|’).
(These values are actually defined in class, ios,
so that all file-related streams may inherit them.) Only some of these
modes are defined in the latest draft ANSI specification; if portability
is important, you may wish to avoid the others.
The last optional argument, prot, is specific to Unix-like systems; it specifies the file protection (by default, 644).
void ifstream::open
(const char*
fname [,
int mode [,
int prot]])
Method
You can write data to class ofstream with any operation from class ostream. The following documentation discusses a few specialized facilities.
ofstream::ofstream
()
Constructor
ofstream::ofstream
(int fd)
Constructor
ofstream::ofstream (const
char* fname [,int
mode [,int
prot]])
Constructor
By default, the file is opened for output (with ios::out as mode). You can use the optional argument, mode, to specify how to open the file, just as described for ifstream::ifstream.
The last optional argument, prot, specifies the file protection (by default, 644).
ofstream::~ofstream
()
Destructor
void
ofstream::open (const
char* fname [,int
mode [,int
prot]])
Method
The class, fstream, combines the facilities of ifstream and ofstream, just as iostream combines istream and ostream.
The class, fstreambase, underlies both ifstream and ofstream. They both inherit the following additional method.
void
fstreambase::close ()
Method