error C2679: binary #39;gt;gt;#39; : no operator found which takes a right-hand operand of type #39;std::string#39; (or there is no acceptable conversion)(错误 C2679:二进制“gt;gt;: 没有找到使用“std::string类型的右侧操作数的运算符(或者没有可接受的转换)) - IT屋-程序员软件开发技术
问题描述
请不要与标题混淆,因为它已经有人问过了,但用于不同的上下文
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::cout 和 std::endl.
On a side note: That should be std::cout and std::endl.
这篇关于错误 C2679:二进制“>>": 没有找到使用“std::string"类型的右侧操作数的运算符(或者没有可接受的转换)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:错误 C2679:二进制“>>": 没有找到使用“std::string"类型的右侧操作数的运算符(或者没有可接受的转换)
基础教程推荐
- 初始化列表*参数*评估顺序 2021-01-01
- 非静态 const 成员,不能使用默认赋值运算符 2022-10-09
- CString 到 char* 2021-01-01
- GDB 显示调用堆栈上函数地址的当前编译二进制文 2022-09-05
- 为什么 typeid.name() 使用 GCC 返回奇怪的字符以及如 2022-09-16
- 通过引用传递 C++ 迭代器有什么问题? 2022-01-01
- 为什么 RegOpenKeyEx() 在 Vista 64 位上返回错误代码 2021-01-01
- 我应该对 C++ 中的成员变量和函数参数使用相同的名称吗? 2021-01-01
- 如果我为无符号变量分配负值会发生什么? 2022-01-01
- 为什么派生模板类不能访问基模板类的标识符? 2021-01-01
