Topic summary

Static (keyword)

Static (keyword)

Reserved word in some programming languages static is a reserved word in many programming languages to modify a declaration. The effect of the keyword varies depending on the details of the specific programming language, most commonly used to modify the lifetime (as a static variable) and visibility (depending on linkage), or to specify a class member instead of an instance member in classes. Origin In the predecessors of C, including BCPL and B, there was already a concept of static storage, which meant a storage which is always in existence. However, In B, there wasn't a static keyword, but there was an extrn keyword to specify external storage (external to all functions and must be defined outside a function), which is always static, in contrast with the auto keyword, which declared a variable with automatic storage – one appears whenever the function is invoked, and disappears when the function returns. All variables must be declared as one of auto, extrn, or implicitly as function arguments. C was developed as a successor of B, and the static and register keywords were added as storage class specifiers, along with auto and extern, which kept their meaning from B. However, in