Is there something -ve about them ie Global Variables.
Is there something -ve about them ie Global Variables.
-
exposes data to all functions in prgram, which may be good or may be bad depending on the circumstances. If you want assurance that a given variable will be affected only by a given function, then keeping scope as local as possible is recommended.
The use of global variables is often considered a serious flaw in the design of your application, but sometimes their use is unavoidable.
"only two things are infinite, the universe and human stupidity, and im not sure about the former." - albert einstein
Global make it more dificult to look after variable names. Once you use a global variable you have to start watching the variable names you use locally, which means you have to start using the scope resalution operator. Just makes things get tricky and get out of hand fast. They take away the elegance of a program and make it more difficult to do "black box" programming depending on how much your overusing them. They have their place though...I like to use them for DirectX sometimes. For simple programs it can be easier than passing a variable all over the place because its needed everywhere.
______________________
The Gekko
The interesting part is that the MS Mfc model relies heavily on global member variables for all there controls. I have not found a way around that when I do win apps.