istream_iterator::char_type

提供 istream_iterator的字元型別的型別。

typedef CharType char_type;

備註

這個型別是樣板參數的 Chartype一個同義資料表。

範例

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

int main( )
{
   using namespace std;

   typedef istream_iterator<int>::char_type CHT1;
   typedef istream_iterator<int>::traits_type CHTR1;

   // Standard iterator interface for reading
   // elements from the input stream:
   cout << "Enter integers separated by spaces & then\n"
        << " any character ( try example: '2 4 f' ): ";

   // istream_iterator for reading int stream
   istream_iterator<int, CHT1, CHTR1> intRead ( cin );

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

   while ( intRead != EOFintRead )
   {
      cout << "Reading:  " << *intRead << endl;
      ++intRead;
   }
   cout << endl;
}
  2、4

FakePre-c3e0e8e54b594f23a181ef1ffe4f4f3e-ed5adab15e2943be96f29d3e9ec204bd

需求

標題: <iterator>

命名空間: std

請參閱

參考

istream_iterator Class

標準樣板程式庫