Obj that needs complete availability
I have a graphics mgr/engine class and every thing in my game needs to access a few of the variables and functions withing it. I thought about using namespaces, but they didn''t work right. Maybe a static variable that everything inherits?
I tried the static ptr option but I got ''undefined'' errors when accessing the engine''s members. Does this mean that I have to include the header in EVERY class that needs it? Am I missing a shortcut or trick?
Thanks in advance..
quote:
Does this mean that I have to include the header in EVERY class that needs it
Yep, if something needs to use a class it also needs to know how to use it.
quote:
Maybe a static variable that everything inherits?
You''ll still need to include the header in the base class of everything, and you''ll also end up with a single rooted class hierarchy. Directly including it in every file that needs is better than doing it this way. But still not great. Having a class that is accessed by everything else often happens when you try to make one class do to much. Thing about what this class is doing, and see if you can split up it''s tasks into smaller classes.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement