class
<ostream> <iostream>

std::basic_ostream

template <class charT, class traits = char_traits<charT> >  class basic_ostream;
Output stream

Output stream objects can write sequences of characters and represent other kinds of data. Specific members are provided to perform these output operations (see functions below).

The standard objects cout, cerr, clog, wcout, wcerr and wclog use particular instantiations of this class template.

Objects of these classes keep a set of internal fields inherited from ios_base and basic_ios:

fieldmember functionsdescription
Formattingformat flagsflags
setf
unsetf
A set of internal flags that affect how certain input/output operations are interpreted or generated.
See member type fmtflags.
field widthwidthWidth of the next formatted element to insert.
display precisionprecisionDecimal precision for the next floating-point value inserted.
localegetloc
imbue
The locale object used by the function for formatted input/output operations affected by localization properties.
fill characterfillCharacter to pad a formatted field up to the field width (width).
Stateerror staterdstate
setstate
clear
The current error state of the stream.
Individual values may be obtained by calling good, eof, fail and bad.
See member type iostate.
exception maskexceptionsThe state flags for which a failure exception is thrown.
See member type iostate.
Othercallback stackregister_callbackStack of pointers to functions that are called when certain events occur.
extensible arraysiword
pword
xalloc
Internal arrays to store objects of type long and void*.
tied streamtiePointer to output stream that is flushed before each i/o operation on this stream.
stream bufferrdbufPointer to the associated basic_streambuf object, which is charge of all input/output operations.

Template parameters

charT
Character type.
This shall be a non-array POD type.
Aliased as member type basic_istream::char_type.
traits
Character traits class that defines essential properties of the characters used by stream objects (see char_traits).
traits::char_type shall be the same as charT.
Aliased as member type basic_istream::traits_type.

Template instantiations

These instantiations are declared in <ostream>, which is included by reference in <iostream>.

Member types

The class contains the following member class:

Along with the following member types:
member typedefinitionnotes
char_typeThe first template parameter (charT)
traits_typeThe second template parameter (traits)defaults to: char_traits<charT>
int_typetraits_type::int_type
pos_typetraits_type::pos_typegenerally, the same as streampos
off_typetraits_type::off_typegenerally, the same as streamoff
And these member types inherited from ios_base through basic_ios:

Public member functions


Formatted output:

Unformatted output:

Positioning:

Synchronization:

Protected member functions


Public member functions inherited from basic_ios


Public member functions inherited from ios_base