how often do you guys tend to use global variables anyway?
how often do you guys tend to use global variables anyway?
I use them quite frequently. But I never show any of my sourcecode to anybody. That saves me from a lot of discussions about their usefullness.Originally Posted by dac
Kurt
In general, global variables should be avoided unless the programmer has a good
reason to use one. In this case, using a static is just hte same, it lasts for the length
of the programs life time and retains its value throughout function calls.
Double Helix STL
how do you guys think i could eliminate the global variables? the program is a for a car breakers (structs a bit of a give away lol), all 15 of the modules are local but i have 4 which arent, holding number of customers which is used by most modules same with vehicles, and also the data structs need to be used by each modules too.Originally Posted by swgh
It is you, who should think about it.how do you guys think i could eliminate the global variables?
If you call some funtion you can pass everithing it needs as parameters instead of accessing globals
All problems in computer science can be solved by another level of indirection,
except for the problem of too many layers of indirection.
– David J. Wheeler