We all know that in C language, different types of variables are stored in memory in different places, from the memory point of view, the different memory blocks of the code or the variables whose properties (mainly scope, life cycle, link
Static global variable and normal global variable, static local variable and ordinary local variable, static function and ordinary function difference? The following article will answer for you.
(1) The description of the global variable
Differences between global variables, local variables, static global variables, and static local variables
C ++ variables have different scopes based on different lifecycles at defined locations. They can be divided into six categories: global
Summary of static keyword function in C + +1. The first and most important article is to introduce it: hide. (static function, static variable all available)When multiple files are compiled at the same time, all global variables and functions that
function declaration and definition variables :Before you talk about variables, let's talk about the concepts of declaring and defining variables.
Declaring a variable means describing the type of the variable to the compiler,
Static in the C language has two functions, the first is a modifier variable , the second is a modifier function .1. Static modifier variableVariables are divided into local variables and global variables, depending on the scope of the action . If
Transfer from: Staticvariable in C and C + + static data member (static member) C language static variables: " Span style= "color: #000000; Font-size:medium; " > 1). Static local variable A, A static local variable is defined
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
Variable scope
Local scope, global scope, file scope
Local Variables : Also called internal variables, declared within the function (including the main function), the scope begins at the declaration of the variable, ending at the end of the
"1" Static:
1 Limit the scope of a variable or function
2 Set the storage domain of the variable
Common to have:
(1) static global variable (2) static local variable (3) static function
(1) Static global variable: 1,static global variable is only
a keyword in c language--static
Static in C language has two functions, the first is to modify the variable , the second is the modifier function .
1. Static modifier variable
According to the scope of action, the variables are divided into local
About Makefile:
How to generate a dynamic-link library and a static-link library, and what is the purpose of generating these libraries.
Both the static library and the dynamic library are created by the. o file.
The naming convention for static
Scope: Range of valid variable namesExistence: A period in which a variable is present in a program.Storage mode: auto, register, extern, staticStorage type: Stacks (stack): variables that are automatically allocated and purged. Such as: local
1. From the scope view:1> Global variables have global scope. A global variable can be used for all source files simply by defining it in one source file. Of course, other source files that do not contain global variable definitions need to declare
1. Basic researchThe program is compiled and connected, and then loaded with Debug.We look at the contents of the main function at offset address 1FA:Execution to 1FD, found that the offset address of N is 01a6, the segment address is stored in the
The role of the static keyword in C languageHuaqing Vision 2014-10-05 Zhang Junhao, Haidian District, BeijingOne, C source program compiled executable (ELF) storage space layout1) The machine instruction part that the body section--CPU executes; a
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
How to layout the memory of C Programming programs
In C, each variable and function has two attributes:Data TypeAndData storage category.Storage Class of local variables and global variables in C Language (static,extern,auto,register)
1. Partition
the static of C + + has two usages: static in process-oriented programming and static in object-oriented programming. The former applies to ordinary variables and functions, and does not involve classes; the latter mainly describes the role of
The 1.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 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.