怎样才能调用string类?

图片说明
main.cpp

#include <iostream>
#include <string>
#include "ClassStudent.h"
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char** argv) {
    Student a(1,'mary','m');
    Student::showCount();
    Student b(2,'mary','m');
    Student::showCount();
    return 0;
}

ClassStudent.cpp

#include "ClassStudent.h"
#include <iostream>

using namespace std;
    int Student::count=0;
    void Student::showCount()
    {
        cout<<count<<endl;
    }

ClassStudent,h

#include <string>
class Student{
    public:
        Student(int num=0,string name='alex',char sex='m'):num(num),name(name),sex(sex){
            count++;
        }
        static void showCount();
    private:
        int num;
        string name;
        char sex;
        static int count;
};
你只在.cpp文件加了
#include <iostream>
using namespace std;


你应该在ClassStudent.h 头文件添加
#include <iostream>
using namespace std;
其他地方可以不加,因为已经使用了
#include "ClassStudent.h"
#include <string>下面加上一个
using namespace std;
看看