Function Call Model Fundamentals
It's actually a constant jump from one memory to another.
function call Variable pass analysis
- A main program has n functions, the C + + compiler will build several heap areas? How many stack areas are there?
A: A program has only one heap area and one stack area.
- When a function is nested, how does the C + + compiler manage the life cycle of a variable when the argument address is passed to the parameter?
The upper-level variable can be used in the next-level invocation, and the parent variable still exists after the parameter is passed. The subordinate variable cannot be called in the ancestor, except for the variable that is opened in the heap area. The life cycle of the upper subordinate variables is mainly due to the characteristics of the stack: first in and out, then in first out
Analysis: function A, call function B, the variable passed by the parameter (memory space can be used?). )
Tip: Establishing the correct program to run the memory layout is the key to learning C.
Attention to the wild hands;
The growth direction of the stack area;
C Language review: Memory model 2