错误 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)

查看:21
本文介绍了错误 C2679:二进制“>>": 没有找到使用“std::string"类型的右侧操作数的运算符(或者没有可接受的转换)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请不要与标题混淆,因为它已经有人问过了,但用于不同的上下文

Visual C++ Compiler (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?

我猜你忘记了.

旁注:那应该是 std::coutstd::endl.

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

这篇关于错误 C2679:二进制“&gt;&gt;": 没有找到使用“std::string"类型的右侧操作数的运算符(或者没有可接受的转换)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆