silvo
Main Ripz
Silvo
I'll Show You Hell, But First Ill Have To Rip Heaven Away From You.
Posts: 191
|
as8q2
Aug 7, 2010 21:01:17 GMT -5
Post by silvo on Aug 7, 2010 21:01:17 GMT -5
Within the areas stated by the {} is called the scope, it is the area to which factors apply.
As such the class has a scope, and each method within it could be seen as a sub-scope. Within is sub-scope a variable could be declared that is only usable within that sub-scope, however a variable declared within the class would be able to be used by all of the sub-scopes.
class Program { float GlobalScope; int main () { float LocalScope; } }
A Global Variable is used when it is needed in multiple areas of the program, and can be easily accessed, however a local variable is used when you only need it for a small portion of the program, or it can be sent through methods into other local variables.
Global variables are always accessable meaning their always taking up space, even when not being used. For this reason it could cause your program to take up an unessisary amount of space and that is one of the last things a programmer ever wants to do.
|
|