Share via


ostream_iterator::operator++

A nonfunctional increment operator that returns an ostream_iterator to the same object it addressed before the operation was called.

ostream_iterator<Type, CharType, Traits>& operator++( );
ostream_iterator<Type, CharType, Traits> operator++( int );

Return Value

A reference to the ostream_iterator.

Remarks

These member operators both return *this.

Example

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

int main( )
{
   using namespace std;

   // ostream_iterator for stream cout
   // with new line delimiter
   ostream_iterator<int> intOut ( cout , "\n" );

   // standard iterator interface for writing
   // elements to the output stream
   cout << "Elements written to output stream:" << endl;
   *intOut = 10;
   intOut++;      // No effect on iterator position
   *intOut = 20;
   *intOut = 30;
}
Elements written to output stream:
10
20
30

Requirements

Header: <iterator>

Namespace: std

See Also

Reference

ostream_iterator Class

Standard Template Library