다음을 통해 공유


ostreambuf_iterator::ostreambuf_iterator

Constructs an ostreambuf_iterator that is initialized to write characters to the output stream.

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

매개 변수

  • _Strbuf
    The output streambuf object used to initialize the output stream-buffer pointer.

  • _Ostr
    The output stream object used to initialize the output stream-buffer pointer.

설명

The first constructor initializes the output stream-buffer pointer with _Strbuf.

The second constructor initializes the output stream-buffer pointer with _Ostr.rdbuf. The stored pointer must not be a null pointer.

예제

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

요구 사항

헤더: <iterator>

네임스페이스: std

참고 항목

참조

ostreambuf_iterator 클래스

표준 템플릿 라이브러리