次の方法で共有


ostream_iterator::operator++

同じオブジェクトに ostream_iterator が返す、機能的なインクリメント演算子は、アクションが呼び出される前に解決します。

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

戻り値

ostream_iteratorへの参照。

解説

これらのメンバー演算子は、*thisを返します。

使用例

// 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;
}
  

必要条件

ヘッダー: の <反復子>

名前空間: std

参照

関連項目

ostream_iterator クラス

標準テンプレート ライブラリ