Click on the banner to return to the class reference home page.

basic_ofstream


basic_ofstreambasic_ostreambasic_iosios_base

Data Type and Member Function Indexes
(exclusive of constructors and destructors)

Synopsis

#include <fstream> 
template<class charT, class traits = char_traits<charT> >
class basic_ofstream
: public basic_ostream<charT, traits>

Description

The template class basic_ofstream<charT,traits> supports writing into named files or other devices associated with a file descriptor. It uses a basic_filebuf object to control the associated sequences. It inherits from basic_ostream and can therefore use all the formatted and unformatted output functions.

Interface

template<class charT, class traits = char_traits<charT> >
class basic_ofstream
: public basic_ostream<charT, traits> {

 public:

  typedef basic_ios<charT, traits>    ios_type;

  typedef charT                       char_type;
  typedef traits                      traits_type;
  typedef typename traits::int_type   int_type;
  typedef typename traits::pos_type   pos_type;
  typedef typename traits::off_type   off_type;

  basic_ofstream();
     
  explicit basic_ofstream(const char *s,
                          ios_base::openmode mode =
                          ios_base::out,
                          long protection = 0666);

  explicit basic_ofstream(int fd);

  basic_ofstream(int fd, char_type* buf, int len);

  virtual ~basic_ofstream();

  basic_filebuf<charT, traits> *rdbuf() const;

  bool is_open();
    
  void open(const char *s, ios_base::openmode mode =
            ios_type::out, long protection = 0666);

  void close();

};

Types

char_type
off_type
ofstream
int_type
ios_type
pos_type
traits_type
wofstream

Constructors

basic_ofstream();
basic_ofstream(const char* s,
               ios_base::openmode mode= ios_base::in,
               long protection= 0666);
explicit basic_ofstream(int fd);
basic_ofstream(int fd, char_type* buf,int len);

Destructor

virtual ~basic_ofstream();

Member Functions

void 
close();
bool 
is_open();
void 
open(const char* s,ios_base::openmode =
          ios_base::out, long protection = 0666);
basic_filebuf<charT,traits>* 
rdbuf() const;

Examples

See basic_fstream, basic_ifstream and basic_filebuf examples.

See Also

char_traits(3C++), ios_base(3C++), basic_ios(3C++), basic_filebuf(3C++), basic_ifstream(3C++), basic_fstream(3C++)

Working Paper for Draft Proposed International Standard for Information Systems--Programming Language C++, Section 27.8.1.8

Standards Conformance

ANSI X3J16/ISO WG21 Joint C++ Committee


©Copyright 1996, Rogue Wave Software, Inc.