ostream_iterator::operator*

取消引用运算符用于实现迭代器输出表达式 *ii = x。

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

返回值

ostream_iterator的引用。

备注

ostream_iterator 迭代器的输出必须满足的要求没有只需要表达式 *ii t = 有效且独立添加有关 运算符operator=。 此实现的成员运算符返回 *this

示例

// ostream_iterator_op_deref.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 类

标准模板库