this
global bad? If so, what can be done to replace it?
Namely, I've got some stuff like:
--- Code ---
DisplayWindow *msgWnd, *gameWnd, *statsWnd;
("globals" within the source file UH OH)
...
(Functions that use them -- this is all you see from "outside")
void InitializeGameDisplay()
{
...}
Your problems start this function. If you don't call it before any
other function, your code will pretty likely crash (e.g. because it
initializes your "globals", and some other function uses them, and if
Init... wasn't called...). And there's a way to explain, through code
organization, proper call order. E.g.
class GameDisplay
{
private:
DisplayWindow gameWindow, msgWnd, statsWnd;
public:
void Whatever()
{ use gameWnd, msgWnd, statsWnd... }
};
If you do the above, you can't make a mistake and not call Init (Init
just became the constructor of your GameDisplay). So perhaps you
should try this line of thinking.
Just thought of something like that. But isn't "game" a singleton