The scope of a variable or object refers to that portion of the program where the variable or object is visible (i.e., where it can be manipulated).
Scope may be global or local.
An object with global scope is declared as a global variable, and can be accessed from anywhere in the program. Global objects exist throughout the execution of the entire program.
Objects with local scope exist for the duration of the program unit (subroutine or block) that contains the declaration. Objects declared within a subroutine or block exist from when control enters the subroutine or block until control leaves. If control returns to the subroutine or block (e.g. by another call) new local objects are created.
home | Home Page |