The data type can be understood as the mold (die) that creates the variable; alias for fixed memory size .
The role of the data type: The amount of memory space allocated by the compiler budget object (variable).
A memory object that can read and write, called a variable, or an object that cannot be modified once initialized is called a constant.
variable Nature : an alias for (a contiguous) memory space.
Four areas of memory
Stack: Also called a staging area, which is automatically assigned by the compiler to release, storing the function's parameter value, the value of the local variable, and so on.
heap: Typically released by programmers (dynamic memory requests and releases), if the programmer does not release, the program may end up being recycled by the operating system.
Global Zone (static zone): The storage of global variables and static variables is placed in a block, initialized global variables and static variables in an area, uninitialized global variables and uninitialized static variables in another adjacent area, which is released by the operating system after the end of the program.
constant Area : The storage location of string constants and other constants, released by the operating system after the program is finished
Program code area : binary code that holds the body of the function.
Function call model
Function 1 calls function 2, function 1 is called the keynote function function 2 is called the called function.
Main (the main function) the allocated memory (in the heap, the stack, the global zone) can be used in the called function.
C + + can allocate memory in the staging area, but it is cleared by the system when it is exhausted.
If you allocate memory in the staging area (stack) inside the called function, the primary call function is not available.
To figure out whether the main function allocates memory, or if the function is called to allocate memory.
How the main melody function uses the memory allocated by the called function (technical key: pointers do function arguments ).
Heap, stack growth direction, and memory storage direction are two different concepts.
Pointer
The 1 pointer is also a variable that occupies memory space and is used to store memory addresses
2 When the pointer is declared, the * number indicates that the variable being declared is a pointer
When the pointer is used, the * number represents the value in the memory space pointed to by the manipulation pointer
*p is equivalent to finding a piece of memory by the address (the value of the P variable), and then manipulating the memory
*p on the left side of the equal sign (assigning values to memory)
*p on the right side of the equal sign (Gets the value from memory)
A 3 pointer variable and the memory block it points to are two different concepts
Meaning 1 assigns p to the value p=0x1111; Only changes the pointer variable value, does not change the meaning of the content; p = P +1;
Meaning 2 assigns a value *p= ' a ' to *p; Does not change the value of the pointer variable, only changes the value of the referred memory block
Meaning 3 = left *p means assigning values to memory, = right *p means different value meanings
4 A pointer is a data type that refers to the data type of the memory space it points to
Meaning 1: Pointer step size (p++), based on the data type of the resulting memory space to determine
Conclusion: The step size of the pointer is determined by the type of memory space referred to.
the above for personal understanding of the summary, reproduced please indicate the source!
Deep understanding of data types, variable type properties, memory Quad, and pointers