vs stdio 报错e0020

  

#include <iostream>
#include<vector>
#include<string.h>
class Person {
public:
    string mname;
    int mage;
    Person(string a, int b) {
        mname = a;
        mage = b;
    }
};
void test01() {
    vector<Person> v;
    Person p1("tom", 18);
    Person p2("jack", 19);
    Person p3("tane", 17);
    Person p4("reo", 18);
    Person p5("jim", 20);
    v.push_back(p1);
    v.push_back(p2);
    v.push_back(p3);
    v.push_back(p4);
    v.push_back(p5);
    for (vector<Person>::iterator it = v.begin(); it != v.end(); it++)
        cout << "name:" << (*it).mname << " age:" << (*it).mage << endl;
}
int main()
{
    test01();
    std::cout << "Hello World!\n";
    return 0;
}

一开始觉得莫名奇妙,之前的都是对的,怎么这个不行,然后发现没写

using namespace std;

加上就不报错了,但是不知道为什么,有人能解答一下吗?

string是字符串类,要使用他首先要#include<string>,其次必须使用 using namespace std; 命名空间。