0

First of all, I'll try to be as precise as my english admit me to be. I am currently building a game engine using the SDL and I've come to a cross-inclusion problem.

I have a class Scene and a class Component. Each scene contains a list of components. I want that each component add themselves to the scene's list of component during their respective construction.

As of that, the Scene must include Component.h and the class Component need to include the Scene.h, thus provoking the cross-inclusion problem.

Is there a way to avoid that?

  • 1
    Yes. Use forward declarations - and see [this Q&A](http://stackoverflow.com/questions/14909997/why-arent-my-include-guards-preventing-recursive-inclusion-and-multiple-symbol) for some more info – Andy Prowl May 06 '13 at 20:49
  • Thank you very much. That was exactly what I was looking for – user2356060 May 06 '13 at 23:15
  • @user2356060 I think it's a good practise to accept this as an answer if you feel helped by this answer! –  May 07 '13 at 17:51

0 Answers0