The scope and life cycle of variables

learning target:

Understand and master the scope and life cycle of variables .


Scope

Scope, the concept of programming. Generally speaking, the name used in a piece of program code is not always valid (available) and the scope of the code that limits the availability of the name is the scope of the name.
For example:
1. The life cycle of a local variable is: the life cycle of entering the scope starts, and the life cycle of out of scope ends.
2. The life cycle of global variables is: the life cycle of the entire program.


life cycle

The life cycle of a variable refers to a period of time between the creation of the variable and the destruction of the variable.
For example:
1. The life cycle of a local variable is: the life cycle of a local variable starts, and the life cycle of a local variable ends.
2. The life cycle of global variables is: the life cycle of the entire program.


Guess you like

Origin blog.csdn.net/qq_52208569/article/details/112853578