You should not be #include
ing at all. Since you only store pointers, you do not need the full definition of the classes - you only need the declaration. Simply use the forward declarations by themselves:
// model.h
class Facet;
class Model {
...
std::map<int, std::vector<Facet*> > enqueue_list_;
}
// facet.h
class Model;
class Facet {
...
Model *parent_;
}
The point of header files is to be able to reuse declarations of functions and objects and definitions of classes in multiple translation units. In this case, you don't need a definition of a class, only a declaration.
As you had it originally, model.h
would include facet.h
would include model.h
would include facet.h
... This clearly leads to an infinite recursive inclusion. If you had include guards on your headers, the infinite recursion would be prevented, but one of the classes would be left not knowing about the other. For example, if model.h
is being preprocessed first, it will include facet.h
and be able to see the definition of Facet
, but then facet.h
wouldn't be able to include model.h
(because of the inclusion guard) and so it wouldn't know anything about Model
.