I have 3 classes which I am going to refer to as A, B and C (names in this example are arbitrary). All 3 of these classes consist of a header-file and a cpp-file each.
I have the following dependencies:
- A needs to know B as A has a member of type B
- B needs to know A and C as B has members of both types
- C needs to know A as C has a member of type A
I have tried out several options already (include this header here, forward-declaration of class there), but compilation was never succesful. I also couldn't extract any helpful information from answers to problems which solved circular inclusion problems between only 2 classes.
EDIT:
Here a minimal (and hopefully sufficient) example of my current setup:
A.h
class A {
private:
B myB;
};
B.h
class B {
private:
A* myA;
C myC;
};
C.h
class C {
private:
A* myA;
}
I should perhaps also note that B::myA and C::myA are always going to point to the same A-instance.