因为string是标准库定义的,所以不需要写#include<string>,只需按照下面方法做即可。 方法1:可以直接包含 using namespace std; 方法二(推荐):使用using std::string;