局部和全局变量之间的差异 [英] Differences between local and global variables
本文介绍了局部和全局变量之间的差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在寻找关于全局范围变量和局部范围变量之间差异的指导。谢谢。
解决方案
全局变量 - 在程序开始时声明,它们的全局范围意味着它们可以用于程序中的任何过程或子程序。
局部变量 - 在子程序或程序块中声明,它们的局部范围意味着它们只能是用在它们声明的子程序或程序块中。
I am looking for some guidance on the difference between a global scope variable and a local scope variable. Thanks.
解决方案
Global variable - declared at the start of the program, their global scope means they can be used in any procedure or subroutine in the program.
Local variable - declared within subroutines or programming blocks, their local scope means they can only be used within the subroutine or program block they were declared in.
Resource: Fundamentals of Programming: Global and Local Variables
Resource: Difference Between Local and Global Variables
这篇关于局部和全局变量之间的差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文