c++ - Declaring a variable as global and then as local -Shadowing- -


what mean declare variable global , re-declare local this:

int = 0; int main() {     int = 7;     return 0; } 

i saw example in reference, don't understand it. please put consideration i'm beginner @ programming c++

this means in main method if use a, refer 1 declared in method, because shadows global one. access global one within main, need access via ::a. within other methods if use a, refer 1 global every method in file. scopes work this, if doesn't find variable, goes , tries find in outer scope , on global scope.

one advice avoid global variables


Comments

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -