I have 3 classes: A, B and C. C is #includeed by B, and B is #included by A. In class C i have defined a handler for a button, and when the button is pushed, C will PostMessage to object A. If i include A in C, i will have a cyclic reference, so what should i do to avoid this cyclic reference?
EDIT: All includes are made in implementation files.
You should use forward declarations. Since
Cis not the owner ofA, I’ll assume you have a pointer as a member. So you don’t need to include:In the implementation file, you’ll include
A.hbut that’s OK. Also, if you can, use forward declarations inA.handB.hwhere possible.