Variables in coding

本文探讨了编程中变量的概念,包括变量的初始化、可见范围与生命周期等内容。介绍了局部与全局变量的区别,以及不同作用域变量的使用特点。

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.


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值