C++中使用字符串时,出现“严重性 代码 说明 项目 文件 行 禁止显示状态错误 C2679 二进制“<<”: 没有找到接受“std::string”类型的右操作数的运算符(或没有可接受的转换)问题”
#include <iostream>
using namespace std;
int main() {
string s;
getline(cin, s);
string s1 = s.substr(5);
cout << s1 << endl;
return 0;
}
解决方法## 标题
`添加头文件#include
#include <iostream>
#include<string>
using namespace std;
int main() {
string s;
getline(cin, s);
string s1 = s.substr(5);
cout << s1 << endl;
return 0;
}
运行结果: