Friend class can't find it's friend - No such file or directory

Hey all

I created two classes, Student and Course.
They are friend classes.
Each class has fields of the other class, meaning:
Student has a field vector <course> and Course has a field vector <Student>.
I have compilation error only in Course.h but not in Student.h.
I also tried #include to each other in both of them and it did not work either.
Any suggestions?

Adding the codes both of the classes if anyone sees something I don't see:


#ifndef COURSE_H_
#define COURSE_H_
#include <iostream>
using namespace std
#include <vector>
#include <string>
#include <Student.h>

class Course {
public:
Course();
virtual ~Course();

private:
string name;
int day;
int vacancy;
vector <Student> studentsTakingTheCourse;
vector <int> idsOfStudentsTakingTheCourse;
friend class Student;
};

#endif /* COURSE_H_ */




#ifndef STUDENT_H_
#define STUDENT_H_
#include <iostream>
using namespace std
#include <vector>
#include <string>


class Student {
public:
Student();
virtual ~Student();

private:
int id;
vector <Course> coursesStudentWantsToTake;
vector <string> namesOfCousesStudentWantsToTake;
vector <Course> coursesTakenByTheStudent;
friend class Course;
};



#endif /* STUDENT_H_ */
Place member declaration

friend class Student;

before

vector <Student> studentsTakingTheCourse;

in class Course.



Actually it didn't seem to be the problem, but after I moved all the #include I had into to class{}, compilation errors stopped.

The problem I have now is that when I try to run a main function that uses for example class Course - it says No such file or directory "Course.h".

Any idea?
Thank you
Topic archived. No new replies allowed.