Archived

This topic is now archived and is closed to further replies.

Trajar

Obj that needs complete availability

Recommended Posts

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..

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Some of the variables are like OffsetX, OffsetY and the mouse coord. These have to be accessed by everyone. I tried makin them static, but I keep getting ''unresolved'' linking errors when I manipulate them. Surely I must be going about this wrong.

Share this post


Link to post
Share on other sites