共用方式為


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。

FakePre-dbb14a96fd2744bb99d81a19f481134e-ff4f9877d3c14996bb1bcc9f9f649316

需求

標題: <iterator>

命名空間: std

請參閱

參考

istream_iterator Class

標準樣板程式庫