Advertisement

Obj that needs complete availability

Started by July 21, 2000 12:08 PM
1 comment, last by Trajar 24 years, 5 months ago
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.
Advertisement
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.

This topic is closed to new replies.

Advertisement