When you create a new pointer, this will be in heap until you delete it. 

So what you said is sort of mistake, "函数内部有个局部变量指针", then the pointer should not exist after the function return.



Therefore, you should delete the pointer before the program is done, or memory leak



int* add(){

int a =1;

int *Ptr=&a;

return Ptr; //for this Ptr is not actual local variable, because it be return, so other can use it

}



int add(){

int a =1;

int *Ptr=&a;

delete Ptr;

return 0; //for this Ptr is local variable, because it was deleted

}

最新文章

  1. SpringMVC 数据校验
  2. 前端相关的seo技术
  3. java日期int和String互转
  4. IOS 项目问题总结
  5. Jedis中的一致性hash
  6. Just do it!!!
  7. UILabel 的属性设置
  8. FileProvider解决FileUriExposedException
  9. “IAsyncOperation<StorageFile>”不包含“GetAwaiter”的定义
  10. NGUI_Font
  11. 【转载】Ubuntu 12.04 LTS 中文输入法的安装
  12. 集群通信组件Tribes之整体介绍
  13. Java框架spring 学习笔记(三):Bean 的生命周期
  14. python全栈开发day85-查:数据表 数据头 增加列 展示多对多字段 反向解析编辑和删除按钮的url
  15. koa执行过程原理分析
  16. 001_linux下的log
  17. Axis2之Spring装配
  18. Spring mvc Json 的正确返回姿势
  19. 异步多线程 Thread ThreadPool Task
  20. LaTeX文章结构

热门文章

  1. 虚拟dom和diff算法
  2. 【转发】【composer】composer 命令行介绍
  3. python--第一类对象,函数名,变量名
  4. Memcached特性及优缺点
  5. UVa 10534 DP LIS Wavio Sequence
  6. Docker存储和网络
  7. Python算法-二叉树深度优先遍历
  8. Maven部署异常:on project standalone-pom: Cannot deploy artifact from the local repository解决方法
  9. 【深度学习一】tensorflow安装
  10. request,response,session,cookie,application