共用方式為


ostream_iterator::operator =

指派運算子用於實作 output_iterator 運算式*撰寫的i = x 寫入輸出資料流。

ostream_iterator<Type, CharType, Traits>& operator=(
   const Type& _Val
);

參數

  • _Val
    型別中插入的物件 Type 的值寫入輸出資料流。

傳回值

運算子 _Val 插入到輸出資料流相關聯的物件,以及分隔符號中指定 ostream_iterator 建構函式 (如果有的話),然後傳回 ostream_iterator的參考。

備註

ostream_iterator 必須滿足的輸出 Iterator 的需求只需要運算式*ii = t 不是有效的而且將相關的說明運算子或 operator=。 這個成員運算子傳回 *this。

範例

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

需求

標題: <iterator>

命名空間: std

請參閱

參考

ostream_iterator Class

標準樣板程式庫