I have a class called Restaurant that contains an Employee member. Now Employee is a friend class of Restaurant. When I try to compile this I get errors on the Employee mCurrentEmployee saying that its missing type specifier - int assumed. Why does the compiler get mad at me for this? Any ideas on how I can fix it? Thanks.
#pragma once
#include "employee.h"
class Restaurant{
friend class Employee;
private:
Employee mCurrentEmployee;
};
-
#pragma once
#include "restaurant.h"
class Employee {
}
If you remove the include
of "restaurant.h"
from employee that should resolve the friend issue (you may need to use forward declarations to get the code to compile but it's impossible to say for certain given the minimal code you've shown us).
That said you should ask yourself why an employee needs to be a friend of restaurant in the first place.