Name
basic_ofstream class template — Class template for file output streams
Synopsis
template <class charT, class traits = char_traits<charT> > class basic_ofstream : public basic_ostream<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_ofstream( ); explicit basic_ofstream(const char* s, ios_base::openmode mode = ios_base::out); basic_filebuf<charT,traits>* rdbuf( ) const; bool is_open( ); void open(const char* s, ios_base::openmode mode = ios_base::out); void open(const char* s, ios_base::open_mode mode); void close( ); };
The basic_ofstream
class
template supports writing to named files using a basic_filebuf<charT
, traits>
object. (See <ostream>
for a description of the
base-class template, basic_ostream
.) In the following member
function descriptions, the file buffer object is assumed to be a
private data member with the name
buf
:
-
basic_ofstream
( )
Initializes the base class with
basic_ostream(&
buf
)
and initializesbuf
with its default constructor.explicit
basic_ofstream
(const
char*
filename, ios_base::openmode
mode
=
ios_base::out)
Initializes the base class and
buf
, then callsopen(filename
,mode)
. Ifopen
returns a null pointer, the constructor callssetstate(failbit)
.basic_filebuf<charT
,traits>*
rdbuf
( )
const
Returns
&
buf
.bool
is_open
( )
Returns
rdbuf( )->is_open( )
.void
open
(const
char*
filename, ...
Get C++ In a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.