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 必须满足的输出迭代的要求只需要该表达式 *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

标准模板库