and for all the reasons that where discussed, globals are not inherently bad. People misuse globals just as they misuse templates or classes, that doesnt make them bad. Poor programming does not make a feature 'bad'. There are many times when globals can easily solve a problem that would otherwise be convoluted or quite frankly impossible to solve. Ultimately there will always be at least some data that MUST be global for any serious project to function. If I have 50 thread functions that all access a common database, I certainly do NOT want to maintain that database seperately for each thread. The simple solution is a global variable. If someone has problems reading -
Code:
extern LPVOID pDatabase;
then they shouldnt be programming in the first place. If they cant find the initial declaration, perhaps they need to check oh, I dont know 'declarations.cpp' or some such.
Crappy programmers shouldn't breathe, that would save us all a lot of problems with people crying about global variables. If you cant handle globals, or you can't use them properly, then don't use them, but don't make high and mighty claims that they are therefore 'BAD'.