Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Please don't confuse with the title as it was already asked by someone but for a different context

The below code in Visual C++ Compiler (VS2008) does not get compiled, instead it throws this exception:

std::ifstream input (fileName);     while (input) {   string s;   input >> s;   std::cout << s << std::endl; }; 

But this code compiles fine in cygwin g++. Any thoughts?

like image 643
asyncwait Avatar asked Oct 27 '09 14:10

asyncwait


1 Answers

Have you included all of the following headers?

  • <fstream>
  • <istream>
  • <iostream>
  • <string>

My guess is you forgot <string>.

On a side note: That should be std::cout and std::endl.

like image 57
sbi Avatar answered Oct 13 '22 09:10

sbi