我尝试编译此代码片段,但出现编译器错误:(!使用 Visual Studio 2010 编译
#include <vector>
#include <string>
#include <sstream>
#include <iterator>
#include <iostream>
using namespace std;
int main() {
string s( "Well well on" );
istringstream in( s );
vector<string> v( istream_iterator<string>( in ), istream_iterator<string>() );
copy( v.begin(), v.end(), ostream_iterator<string>( cout, "\n" ) );
}
错误:
Error 1 error C2228: left of '.begin' must have class/struct/union c:\visual studio 2008 projects\vector test\vector test\main.cpp 13 vector test
Error 2 error C2228: left of '.end' must have class/struct/union c:\visual studio 2008 projects\vector test\vector test\main.cpp 13 vector test
发生了什么?向量构造正确,我怎么不能调用它?
最好的祝福,