difference between static variable and global variable
difference between static variable and global variable
Alibabacloud.com offers a wide variety of articles about difference between static variable and global variable, easily find your difference between static variable and global variable information here online.
The 1.static global variable is only initialized once, preventing it from being referenced in other file units;2.static Local variables are initialized only once, the next time based on the last result value;The 3.static function has only one copy
1, can local variables and global variable duplicate?
A: Yes, the local will screen the overall situation. To use a global variable, you need to use the "::"
Local variables can have the same name as global variables, and when referenced within a
(1) What is the difference between a static global variable and a normal global variable?(2) What is the difference between static local variables and ordinary local variables?(3) What is the difference between the static function and the normal
(1) What is the difference between a static global variable and a normal global variable?(2) What is the difference between static local variable and ordinary local variable?(3) What is the difference between the static function and the normal
Original blog, reprint please indicate the source--Zhou Xuewei http://www.cnblogs.com/zxouxuewei/Static is used in two ways: static in process-oriented programming and static in object-oriented programming. The former applies to ordinary variables
First, the preparation of knowledge-Program memory allocation
The memory used by a program compiled by C + + is divided into the following sections
1, stack area (stack)-by the compiler automatically assigned to release, store the function of the
the difference between static variable and ordinary variable
The description of the global variable (external variable) before being labeled static constitutes a static global variable. The global variable itself is the static storage mode, static
The difference between a global variable and a static global variableThe global variable itself is the static storage mode, static global variables are of course also static storage mode. The two are not different in the way they are stored. The
The 1.c/c++ variable has different scopes according to the different life cycles of the defined positions, and the scope can be divided into 6 types:Global scopes, local scopes, statement scopes, class scopes, namespace scopes, and file scopes.From
The scope of the global variable is defined at the end of the source file, the storage period is defined and the memory is allocated, and the program releases memory after exiting;
Local variable scope is local, storage period is defined after
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.