We have extern type of variable, this
refers to the global variable. When we have multiple files for one
project/program that is too big, then the global variable in main file is
declared with the prefix extern in other files. This declaration is actually
not the creation of another global variable rather to refer the existing global
variable in the main file. We have option in C++ to keep the variable in
cpu/cache memory instead of primary memory when the one is needed to be used
repeatedly or to speed up the execution of the program. CPU/cache memories are
way faster than primary memory. We need to prefix the word register at the time
of declaration of the variable. Unlike auto variable static variable does not
destroy when the block/function is exited in which they have been declared,
rather they stay alive till the time the program is executed. Static variables
are created once when the function is called first time and retain their value
and the same variable is accessed when the function is called again.