user2774643
user2774643

Reputation: 19

error C2678: binary '>>' : no operator found which takes a left-hand operand of type 'std::istream' (or there is no acceptable conversion)

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    }

Upvotes: 0

Views: 11491

Answers (3)

Lukas Kalinski
Lukas Kalinski

Reputation: 2243

In my case, the error appeared when I did this:

volatile int a;
std::cin << a;

Obviously, the << operator is not overloaded for volatile int and thus removing 'volatile' is the solution.

Upvotes: 0

nvoigt
nvoigt

Reputation: 77285

You need to #include<string> and #include<iostream>

Upvotes: 1

Ivaylo Strandjev
Ivaylo Strandjev

Reputation: 70931

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

Upvotes: 5

Related Questions