Reputation: 643
I now working on project with alot of classes and sometimes i need to include like :
CSConnection.h in Player.h and Player.h in CSConnection.h, and now there my compiler got conflicts like Class name was not defined.
Headers had guard, where is problem ?
Upvotes: -6
Views: 82
Reputation: 60027
Forward declaration - see http://en.wikipedia.org/wiki/Forward_declaration or Perhaps the use of a guard 'i.e. #ifdef ...' - http://en.wikipedia.org/wiki/Include_guard
Upvotes: 0
Reputation: 533
Include guards prevent a file from being included multiple times within the same file, but can not help you with cyclic includes. What you probably want is forward declaration, but that depends on what's in your include files.
Upvotes: -1
Reputation: 2147
Circular dependencies are just bad design. If you feel the urge to have a child/owned object "know about" its parent/owner, you should pass the child a std::function instead of a full reference to the owner.
Upvotes: 1