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
时间: 2023-12-19 12:04:26 浏览: 31
这个错误是因为你在尝试使用 cout << 输出一个字符串对象,但是 C++ 的标准输出流不支持输出字符串对象。解决这个问题的方法是将字符串对象转换为 C 风格的字符串,可以使用 string 类的 c_str() 函数来实现。例如:
```
std::string s = "Hello, world!";
std::cout << s.c_str() << std::endl;
```
这样就能够输出字符串对象了。