[Home]
[Edit this page]
[Recent Changes]
[Special Pages]
[Help]
Scope
In one's code (though usually not at runtime), the scope of a variable can be extended across multiple calls to its parent function by declaring it static. The scope of variables can be further extended by making them global, either by setting them as such when defining them, or by initially defining them outside of any function, method, or class definition. The scope of functions, methods and other logical blocks of code can be extended through use of header files.
C++ specific link
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
Scope
Scope
The fixed hierarchical range of a defined item. An item such as a variable, data structure, unity, array, function, method, etc. is limited by its scope. For example, the scope of a variable is the area where the variable's name is valid. Typically, a variable declared inside a function is compiled as a local variable, and is therefore only valid inside the function. Thus its scope is inside the function. If the current value of a variable will be needed by a different function being called, it would need to be passed as a parameter or have its original scope extended.In one's code (though usually not at runtime), the scope of a variable can be extended across multiple calls to its parent function by declaring it static. The scope of variables can be further extended by making them global, either by setting them as such when defining them, or by initially defining them outside of any function, method, or class definition. The scope of functions, methods and other logical blocks of code can be extended through use of header files.
C++ specific link
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
