istream_iterator::operator++
從輸入資料流中遞增的物件或在將它之前複製物件並傳回複本。
istream_iterator<Type, CharType, Traits, Distance>& operator++( );
istream_iterator<Type, CharType, Traits, Distance> operator++( int );
傳回值
第 10% 成員運算子會從輸入資料流傳回在擷取的型別 型別 遞增物件的參考,而第二 + 成成員函式會傳回物件的複本。
範例
// istream_iterator_operator_incr.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-75f20125e21045aea1326fc657b1b4cd-72abc272b0024305a0f0d3a9a7f56ec8
需求
標題: <iterator>
命名空間: std