Collected several reasons for less global variables, welcome to add ~
The first, the resource, the global variable, is before the program runs, there is.
Second, if the program is large, it is possible to define the same name, which is easy to mistake.
Thirdly, local variables can be substituted for all variables.
Four, the global variable is many, and other functions integration, inconvenient.
The global variable causes some functions to be non-reentrant. (non-reentrant means that when the program runs, it suddenly goes somewhere else to run, and then goes back to this place to run, and the run error occurs.) The meaning is simple, is a global variable, when a program runs, changes its value, and then suddenly break to another place, and then change its value, and then go back to the original place to run, there is an error, this is not re-entry. )
Six, the global variable destroys the program structure: for example, give you a function interface, you go to fill, but you have to use global variables, so you need to add your global variables in the main program, therefore, the program framework, there has been a little change.
Reasons to use less global variables