The ostream class lets you use the output operator << to perform formatted output, or insertion, to a stream buffer. Consider the following statement, where outs is a reference to an ostream object and x is a variable of a built-in type:
outs << x;
The output operator << calls opfx() before beginning insertion. If opfx() returns a nonzero value, the output operator converts x into a series of characters and inserts these characters into the stream buffer attached to outs. If an error occurs, the output operator sets ios::failbit.
The details of the conversion of x depend on the format state of the ostream object and the type of x. For numeric and string values, including the char* types and wchar_t*, but excluding the char types and wchar_t, the output operator resets the width variable ios::x_width of the format state of an ostream object to 0, but it does not affect anything else in the format state.
The output operator is defined for the following types:
You can also define output operators for your own types.
Class header file: iostream.h