Share on Facebook Share on Twitter Email
Answers.com

Static variable

 
Sci-Tech Dictionary: static variable
(′stad·ik ′ver·ē·ə·bəl)

(computer science) A local variable that does not cease to exist upon termination of the block in which it can be accessed, but instead retains its most recent value until the next execution of this block.


Search unanswered questions...
Enter a question here...
Search: All sources Community Q&A Reference topics
Wikipedia: Static variable
Top

In computer programming, a static variable is a variable that has been allocated statically — whose lifetime extends across the entire run of the program. This is in contrast to the more ephemeral automatic variables, whose storage is allocated and deallocated on the call stack; and in contrast to objects whose storage is dynamically allocated.

In many programming languages, such as Pascal, all local variables are automatic and all global variables are allocated statically. In these languages, the term "static variable" is generally not used, since "local" and "global" suffice to cover all the possibilities.

In the C programming language and its descendants, the term static variable has at least three separate meanings, each related to the semantics of C's static keyword:

  • Static global variables are declared as "static" at the top level of a source file. Such variables are not visible outside the source file ("file scope"), unlike variables declared as "extern".
  • Static local variables are declared inside a function, just like automatic local variables. They have the same scope as normal local variables, differing only in "storage duration": whatever values the function puts into static local variables during one call will still be present when the function is called again.

See also

References


 
 

 

Copyrights:

Sci-Tech Dictionary. McGraw-Hill Dictionary of Scientific and Technical Terms. Copyright © 2003, 1994, 1989, 1984, 1978, 1976, 1974 by McGraw-Hill Companies, Inc. All rights reserved.  Read more
Wikipedia. This article is licensed under the Creative Commons Attribution/Share-Alike License. It uses material from the Wikipedia article "Static variable" Read more