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:
“These native villages are as unchanging as the woman in one of their stories. When she was called before a local justice he asked her age. I have 45 years. But, said the justice, you were forty-five when you appeared before me two years ago. Señor Judge, she replied proudly, drawing herself to her full height, I am not of those who are one thing today and another tomorrow!”
—State of New Mexico, U.S. public relief program (1935-1943)
“Science is feasible when the variables are few and can be enumerated; when their combinations are distinct and clear. We are tending toward the condition of science and aspiring to do it. The artist works out his own formulas; the interest of science lies in the art of making science.”
—Paul Valéry (18711945)