理解程序代码在内存中的位置
https://www.cnblogs.com/bookdrip/articles/9843958.html
动态存储分配的含义:有些操作对象只在程序运行时才能确定,这样编译时就无法为他们预定存储空间,只能在程序运行时,系统根据运行时的要求进行内存分配,这种方法称为动态存储分配。
C++中内存的基本操作
new delete
new的基本功能是分配内存以及调用构造函数
基本示例
- 一个变量的存储
int *pi=new int(0);//附带初始化为0
delete pi;
- 多个变量的存储
int *pi=new int[];
delete []pi;
C中内存的基本操作
malloc free
malloc free 是一个成对出现的操作,当出现了 **的时候,就需要用循环结构来进行删除
基本实例
- 指针变量
char * a= (char *)malloc(2*sizeof(char))
free(a);
2.指针的指针
...待续