<Tr> <Td> </Td> <Td> This article needs additional citations for verification . Please help improve this article by adding citations to reliable sources . Unsourced material may be challenged and removed . (July 2009) (Learn how and when to remove this template message) </Td> </Tr> <P> In computer programming, a global variable is a variable with global scope, meaning that it is visible (hence accessible) throughout the program, unless shadowed . The set of all global variables is known as the global environment or global state . In compiled languages, global variables are generally static variables, whose extent (lifetime) is the entire runtime of the program, though in interpreted languages (including command - line interpreters), global variables are generally dynamically allocated when declared, since they are not known ahead of time . </P> <P> In some languages, all variables are global, or global by default, while in most modern languages variables have limited scope, generally lexical scope, though global variables are often available by declaring a variable at the top level of the program . In other languages, however, global variables do not exist; these are generally modular programming languages that enforce a module structure, or class - based object - oriented programming languages that enforce a class structure . </P> <P> Interaction mechanisms with global variables are called global environment (see also global state) mechanisms . The global environment paradigm is contrasted with the local environment paradigm, where all variables are local with no shared memory (and therefore all interactions can be reconducted to message passing). </P>

Where is a variable that has class or global scope declared