c++ Can a class contain a class member that is friends with it? -
i have class called restaurant contains employee member. employee friend class of restaurant. when try compile errors on employee mcurrentemployee saying missing type specifier - int assumed. why compiler mad @ me this? ideas on how 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 remove include
of "restaurant.h"
employee should resolve friend issue (you may need use forward declarations code compile it's impossible given minimal code you've shown us).
that said should ask why employee needs friend of restaurant in first place.