次の方法で共有


ostreambuf_iterator::ostreambuf_iterator

ostreambuf_iterator を構築します出力ストリームに文字を記述するために初期化される。

ostreambuf_iterator( 
   streambuf_type* _Strbuf 
) throw( ); 
ostreambuf_iterator( 
   ostream_type& _Ostr 
) throw( );

パラメーター

  • _Strbuf
    出力ストリーム バッファーのポインターを初期化するために使用される出力 streambuf オブジェクト。

  • _Ostr
    出力ストリーム バッファーのポインターを初期化するために使用される出力ストリーム オブジェクト。

解説

最初のコンストラクターは _Strbufの出力ストリーム バッファーのポインターを初期化します。

2 番目のコンストラクターは _Ostrの出力ストリーム バッファーのポインターを初期化します。rdbuf。 格納されているポインターは null ポインターである必要があります。

使用例

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

int main( )
{
   using namespace std;

   // ostreambuf_iterator for stream cout
   ostreambuf_iterator<char> charOut ( cout );
   
   *charOut = 'O';
   charOut ++;
   *charOut  = 'U';
   charOut ++;   
   *charOut = 'T';
   cout << " are characters output individually." << endl;

   ostreambuf_iterator<char> strOut ( cout );
   string str = "These characters are being written to the output stream.\n ";
   copy ( str.begin ( ), str. end ( ), strOut );
}
  

必要条件

ヘッダー: の <反復子>

名前空間: std

参照

関連項目

ostreambuf_iterator クラス

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