ostream::ostream [constructor]
explicit  ostream (streambuf * sb);
ostream
  cplusplus.com  

Construct an object.
  Sets the initial values to inherited class members.
  This is done by calling inherited function:
   init(sb)

Parameters.

sb
pointer to a streambuf object.

Return Value.
  None (constructor).

Example.

// ostream constructor
#include <iostream>
#include <fstream>
using namespace std;

int main () {
  filebuf fb;
  fb.open ("test.txt",ios::out);
  ostream os(&fb);
  os << "Test sentence\n";
  fb.close();
  return 0;
}
  This code uses a filebuf object (derived from streambuf) to open the file test.txt. The buffer is passed as parameter to the ostream constructor, associating it to the stream.
  You will seldom construct ostream objects directly like in the previous example, you will rather use objects of derived classes like ofstream, ostringstream or your own ones.

Basic template member declaration ( basic_ostream<charT,traits> ):
explicit basic_ostream ( basic_streambuf<charT,traits>* sb );

See also.
  ios::init
  ostream class


© The C++ Resources Network, 2001