A header-file should be relatively "complete on it's own". Having a whole bunch of little header files that you need to include all (or nearly all) of to make a useful program serves no purpose.
Obviously, if you have a large set of functions that belong together, then you would want to have that as a separate header, simply to keep the size of headers down. But that would be unusual.
Okay, one more question. I have a class that's made up entirely of static variables used throughout the program, such as screen size, number of objects, and general stuff like that. I'm next to positive that a class isn't the way to group them. So how should I? Should I make them global?
What exactly do you mean by "general stuff"?Quote:
Originally Posted by G4B3
Or make it a regular object, and pass it around (by (const) reference to the various places it is needed).
Or make it a singleton object.
How is that different from just having global variables?Quote:
However, if you have a bunch of things that you need to access all over the program, making a structure that holds them, and have one global instance of that structure MAY be a solution.
That's what I did in Java, but only because we can't have global variables in Java.
You can also prefix your globals with g_. Now, what's the difference again?
As I said, ideally, you should have NO global data. But sometimes it's either awkward to get the right data from the place that knows the right stuff, to where it is needed later on (and it may need to persist across multiple object instance construction/destruction), so it is after all "better" to have a global collection of variables.
In my view, the standard method of a singleton class is pretty close to a global variable as well.
What about putting them into a separate namespace rather than a class?
(although, from the sounds of it, I think a class is the right place)