共用方式為


ostreambuf_iterator::operator*

A nonfunctional dereferencing operator used to implement the output iterator expression *i = x.

ostreambuf_iterator<CharType, Traits>& operator*( );

Return Value

The ostreambuf iterator object.

Remarks

This operator functions only in the output iterator expression *i = x to output characters to stream buffer. Applied to an ostreambuf iterator, it returns the iterator; *iter returns iter,

Example

// ostreambuf_iterator_op_deref.cpp
// compile with: /EHsc
#include <iterator>
#include <vector>
#include <iostream>

int main( )
{
   using namespace std;

   // ostreambuf_iterator for stream cout
   // with new line delimiter
   ostreambuf_iterator<char> charOutBuf ( cout );

   // Standard iterator interface for writing
   // elements to the output stream
   cout << "Elements written to output stream:" << endl;
   *charOutBuf = 'O';
   charOutBuf++;   // no effect on iterator position
   *charOutBuf = 'U';
   *charOutBuf = 'T';
}
Elements written to output stream:
OUT

Requirements

Header: <iterator>

Namespace: std

See Also

Reference

ostreambuf_iterator Class

Standard Template Library