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

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -