Static Local Variables
A special type of local variable, called a static local, is available in many mainstream languages (including C/C++, Visual Basic, and VB.NET) which allows a value to be retained from one call of the function to another. In this case, recursive calls to the function also have access to the (single, statically allocated) variable. In all of the above languages, static variables are declared as such with a special storage class keyword (e.g., static).
Static locals in global functions can be thought of as global variables, because their value remains in memory for the life of the program. The only difference is that they are only accessible (i.e., scoped) to one function.
This is distinct from other usages of the static keyword, which has several different meanings in various languages.
Read more about this topic: Local Variable
Famous quotes containing the words local and/or variables:
“The improved American highway system ... isolated the American-in-transit. On his speedway ... he had no contact with the towns which he by-passed. If he stopped for food or gas, he was served no local fare or local fuel, but had one of Howard Johnsons nationally branded ice cream flavors, and so many gallons of Exxon. This vast ocean of superhighways was nearly as free of culture as the sea traversed by the Mayflower Pilgrims.”
—Daniel J. Boorstin (b. 1914)
“The variables are surprisingly few.... One can whip or be whipped; one can eat excrement or quaff urine; mouth and private part can be meet in this or that commerce. After which there is the gray of morning and the sour knowledge that things have remained fairly generally the same since man first met goat and woman.”
—George Steiner (b. 1929)