且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

错误C2678:binary'>> :无操作符,找到一个类型为“std :: istream”的左手操作数(或没有可接受的转换)

更新时间:2023-11-11 20:50:40

c $ c> #include< string> 。此外,如果您没有添加 #include< iostream> #include< vector> / p>

I found this compiling error very odd . error C2678: binary '>>' : no operator found which takes a left-hand operand of type 'std::istream' (or there is no acceptable conversion) I'm compiling under MVC++ Express 2010 here's the code :

The error indicate that it's from line 8 .

1    int m;
2    vector <string> grid;
3
4    cin >> m;
5
6    for(int i=0; i<m; i++) {
7       string s; 
8   cin >> s;
9        grid.push_back(s);
10    }

You need to #include <string>. Also if you don't have them add #include <iostream> and #include <vector>.