istream_iterator::operator*

的取消引用运算符返回 istream_iterator解析的类型 *** 类型 *** 中的对象。

const Type& operator*( ) const;

返回值

类型 ***** 类型 *****中的对象。

示例

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

int main( )
{
   using namespace std;

   cout << "Enter integers separated by spaces & then\n"
        << " a character ( try example: '2 4 6 8 a' ): ";

   // istream_iterator from stream cin
   istream_iterator<int> intRead ( cin );

   // End-of-stream iterator
   istream_iterator<int> EOFintRead;

   while ( intRead != EOFintRead )
   {
      cout << "Reading:  " << *intRead << endl;
      ++intRead;
   }
   cout << endl;
}
  2 4 6 8。
  2 4 6 8。
输入空格&分隔整数然后字符(尝试示例:“2 4 6 8):2 4 6 8读取:2为:4为:6为:8

要求

标头: <iterator>

命名空间: std

请参见

参考

istream_iterator Class

标准模板库