Dark horse programmer's ingenuity-c++ core programming-memory partition model

 

 

Stack area:

Local variables are stored in the stack area, and the stack area data is automatically released after the function is executed, so do not return the address of the local variable.

Stack area:

a is a pointer variable opened in the stack area, which stores the address of new int(10), and new int(10) is a variable opened in the heap area.

 

Usage of the new keyword:

new int[10] returns the first address of an array of size 10, a[0] represents the first value of the array! ! ! Use the pointer variable arr to receive the first address. 

Guess you like

Origin blog.csdn.net/yyyllla/article/details/109321790