首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

istream_iterator有关问题

2012-02-23 
istream_iterator问题为什么我的编译不过去?需要include什么东西?谢谢!#includeiostream#includevector

istream_iterator问题
为什么我的编译不过去?需要include什么东西?谢谢!

      #include   <iostream>
      #include   <vector>
      #include   <string>
      #include   <algorithm>
      using   namespace   std;
      int   main()
      {
              vector <string>   coll;
              /*read   all   words   from   the   standard   input
                *   -   source:   all   strings   until   end-of-file   (or   error)
                *   -   destination:   coll   (inserting)
                */
              copy   (istream_iterator <string> (cin),             //start   of   source
                          istream_iterator <string> (),                   //end   of   source
                          back_inserter(coll));                               //destination
              //sort   elements
              sort   (coll.begin(),   coll.end());
              /*print   all   elements   without   duplicates
                *   -   source:   coll
                *   -   destination:   standard   output   (with   newline   between   elements)
                */
              unique_copy   (coll.begin(),   coll.end(),                                 //source
                                        ostream_iterator <string>   (cout,   "\n "));
//destination
      }


下面是报的错。
   
[cry@localhost   C++自己练习]$   g++   -o   istream   istream.cpp
istream.cpp:   In   function   ‘int   main()’:
istream.cpp:13:   错误:‘istream_iterator’   在此作用域中尚未声明
istream.cpp:13:   错误:expected   primary-expression   before   ‘> ’   token
istream.cpp:14:   错误:expected   primary-expression   before   ‘> ’   token
istream.cpp:14:   错误:expected   primary-expression   before   ‘)’   token
istream.cpp:23:   错误:‘ostream_iterator’   在此作用域中尚未声明
istream.cpp:23:   错误:expected   primary-expression   before   ‘> ’   token
[cry@localhost   C++自己练习]$

[解决办法]
#include <iterator>

热点排行