View Single Post
  #4   Spotlight this post!  
Unread 23-01-2007, 22:36
Jimmy Cao Jimmy Cao is offline
Registered User
AKA: Jimmy Cao
no team
 
Join Date: Sep 2006
Rookie Year: 2004
Location: San Francisco, CA
Posts: 295
Jimmy Cao has a brilliant futureJimmy Cao has a brilliant futureJimmy Cao has a brilliant futureJimmy Cao has a brilliant futureJimmy Cao has a brilliant futureJimmy Cao has a brilliant futureJimmy Cao has a brilliant futureJimmy Cao has a brilliant futureJimmy Cao has a brilliant futureJimmy Cao has a brilliant futureJimmy Cao has a brilliant future
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