错误C2679:二进制'>' :未找到采用'std :: string'类型的右侧操作数的运算符(或没有可接受的转换) [英] error C2679: binary '>>' : no operator found which takes a right-hand operand of type 'std::string' (or there is no acceptable conversion)
本文介绍了错误C2679:二进制'>' :未找到采用'std :: string'类型的右侧操作数的运算符(或没有可接受的转换)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
请不要与标题相混淆,因为有人已经问过了,但是针对其他上下文
Visual中的以下代码C ++编译器(VS2008)不会得到编译,而是引发以下异常:
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;
};
但是此代码在cygwin g ++中可以很好地编译。有什么想法吗?
But this code compiles fine in cygwin g++. Any thoughts?
推荐答案
您是否包含以下所有标头?
Have you included all of the following headers?
-
< fstream>
-
< istream>
-
< iostream>
-
< string>
<fstream>
<istream>
<iostream>
<string>
我的猜测是你忘记了< string>
。
My guess is you forgot <string>
.
注意:应该是 std :: cout
和 std :: endl
。
这篇关于错误C2679:二进制'>' :未找到采用'std :: string'类型的右侧操作数的运算符(或没有可接受的转换)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文