我有以下C代码:
typedef istream_iterator<string> isi; // (1) vector<string> lineas(isi(cin),isi()); // (2) //vector<string> lineas; //copy(isi(cin),isi(),back_inserter(lineas)); typedef vector<string>::iterator vci; for (vci it = lineas.begin(); it != lineas.end(); ++it) cout << *it << endl;
但是,我在编译时遇到错误:
test.cpp: In function 'int main(int,char**)': test.cpp:16: error: request for member 'begin' in 'lineas',which is of non-class type 'std::vector<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::allocator<std::basic_string<char,std::allocator<char> > > >(main(int,char**)::isi,main(int,char**)::isi (*)())' test.cpp:16: error: request for member 'end' in 'lineas',char**)::isi (*)())'
但是,如果我用(2)替换(1),它就会编译.
我正在使用g 4.4.0
怎么了?