No matter what computer languages you are coding, you have to know variables. I am going to discuss about variables in this essay.
1. Initialization of variables
Any variable can be initialized during definition. If a variable is not initialized explicitly, the value stored in this variable can be any. Implicit
is not used.
Global variable initialization is performed only once
Static variable initialization is performed only once
Local variable initialization is made every time you call the corresponding functions
2. Visibility scope and lifetime of variables (Access to variables)
There are two basic types of scope:
local scope and global scope
2.1 Access to variables
Access to variables can be done from anywhere in the program. These variables are located in the global pool of memory, so their lifetime coincides with the lifetime of the program.
A variable declared locally, is located on the stack, and the lifetime of such a variable is equal to the lifetime of the function.
本文探讨了编程中变量的概念,包括变量的初始化、可见范围与生命周期等内容。介绍了局部与全局变量的区别,以及不同作用域变量的使用特点。
1396

被折叠的 条评论
为什么被折叠?



