|
Re: Why Static Variables?
If you use a global variable, it is easier to accidentally screw it up, by accidentally reusing the same name in a different function. Since static variables only stay in the function it was constructed in, the same name can be used in various places. For example, variable names like "count" and "loops" might be used more than one time in your code. If they were global, that would cause a problem, however a static would allow you to do this without problems.
__________________
Jimmy Cao
Team 469 2006-2010 Student/Alumni
Team 830 2011-2012 Mentor
|