In the scope of C ++ variables (1), the static variables defined by static variables are added that static variables are always in the static storage zone from the beginning to the end of the program, the address is fixed, so any operation on it will be retained. Even if a variable is declared and defined in a function, it will still exist in a static zone for a long time and cannot be used by other functions or other places, static variables are classified as static variables, but there are still local and global variables.
In C ++ variable scope (1), it is also said that adding the const modifier before the variable indicates that the variable can only be valid in the CPP, but can the variables defined by const be accessed in other files? The answer is yes, but the format must be shown in the following Demo, for example:
1/** // file1.cpp ////// //////////////////////////////////
2
3 Extern const int a = 1;
4
5/** // file. cpp /////////////////////////////////////// ///
6
7 Include <iostream>
8
9 Using namespace std;
10
11 Extern const int;
12
13 Cout <a <endl; // print 1