my question is how can i put classes in different files and make the program work?I get error when i try to build and run it at the Student.h file ---> string does not name a type
main.cpp :
#include <iostream>
#include "Student.h"
using namespace std;
int main()
{
Student *a;
a = new Student(1,"Astudent");
a->printStudent();
system("PAUSE");
return 0;
}
Student.h:
#ifndef STUDENT_H
#define STUDENT_H
class Student
{
private:
int id;
string name;
public:
Student(int id,string name);
void printStudent();
};
#endif
Student.cpp:
#include <iostream>
#include "Student.h"
using namespace std;
Student::Student(int id,string name)
{
this->id = id;
this->name = name;
}
Student::printStudent()
{
cout << id << "." << name << endl;
}