error C2679: binary '=' : no operator defined which takes a right-hand operand of type 'class std::basic_string<char,struct std:
时间: 2024-04-19 20:29:24 浏览: 39
这个错误是由于没有定义接受右操作数为类型为 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char>>' 的赋值运算符导致的。这通常发生在你尝试将一个字符串赋值给一个不兼容的类型上。你可以尝试使用适当的转换或者重载赋值运算符来解决这个问题。
相关问题
C:\Users\GIGA\Desktop\1.cpp(7) : error C2632: 'long' followed by 'long' is illegal C:\Users\GIGA\Desktop\1.cpp(8) : error C2679: binary '<<' : no operator defined which takes a right-hand operand of type 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' (or there is no acceptable conversion) error C2679: binary '<<' : no operator defined which takes a right-hand operand of type 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' (or there is no acceptable conversion)
这些错误是由于C++代码中的一些问题引起的。第一个错误是因为在代码中使用了两个连续的long类型,这是不合法的。可能是在某个地方出现了重复的类型定义或者声明。第二个错误是因为在代码中使用了cout输出一个字符串,但是没有正确地包含相关的头文件,导致编译器无法找到适当的重载运算符<<。你可以检查一下代码中的这些部分,看看是否存在错误或者遗漏的内容。
C:\Users\Administrator\Desktop\Cpp1.cpp(36) : error C2679: binary '<<' : no operator defined which takes a right-hand operand of type 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' (or there is no acceptabl
这个错误是因为你在尝试使用 cout << 输出一个字符串对象,但是 C++ 的标准输出流不支持输出字符串对象。解决这个问题的方法是将字符串对象转换为 C 风格的字符串,可以使用 string 类的 c_str() 函数来实现。例如:
```
std::string s = "Hello, world!";
std::cout << s.c_str() << std::endl;
```
这样就能够输出字符串对象了。