Dealing with circular inclusion in a parent/child class relationship
问题 Assume I've made a class, say Parent , that has a composition relation with Child . The parent class holds a list of children. I want all children to hold a reference to the parent, so every child holds a Parent pointer. This will cause circular inclusion. I refer to Child in parent.h and I refer to Parent in child.h . Therefore Parent will need to include Child , which needs to include Parent . What's the best way to work around this? 回答1: You'll have to use forward declaration: //parent.h