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

}

Answer's Question about pointer的更多相关文章

  1. Stack-overflow, how to answer

    How to Answer Welcome to Stack Overflow! Thanks for taking the time to contribute an answer. It's be ...

  2. HOW TO ANSWER: Tell Me About Yourself

    https://biginterview.com/blog/2011/09/tell-me-about-yourself.html There are some job interview quest ...

  3. Question: Database Of Tumor Suppressors And/Or Oncogenes

    https://www.biostars.org/p/15890/     71   5.9 years ago by Malachi Griffith ♦16k Washington Univers ...

  4. Codeforces Round #602 (Div. 2, based on Technocup 2020 Elimination Round 3) F2. Wrong Answer on test 233 (Hard Version) dp 数学

    F2. Wrong Answer on test 233 (Hard Version) Your program fails again. This time it gets "Wrong ...

  5. Learning Conditioned Graph Structures for Interpretable Visual Question Answering

    Learning Conditioned Graph Structures for Interpretable Visual Question Answering 2019-05-29 00:29:4 ...

  6. DrQA 阅读维基百科来回答开放问题 Reading Wikipedia to Answer Open-Domain Questions

    DrQA 是一个阅读理解系统用在开放领域问答.特别的,DrQA 针对一个机器阅读任务.在这个列表里,我们为一个潜在非常大的预料库中搜索一个问题的答案.所以,这个系统必须结合文本检索和机器文本理解. 项 ...

  7. RFID 读写器 Reader Writer Cloner

    RFID读写器的工作原理 RFID的数据采集以读写器为主导,RFID读写器是一种通过无线通信,实现对标签识别和内存数据的读出和写入操作的装置. 读写器又称为阅读器或读头(Reader).查询器(Int ...

  8. DTrace to Troubleshoot Java Native Memory Problems

    How to Use DTrace to Troubleshoot Java Native Memory Problems on Oracle Solaris 11 Hands-On Labs of ...

  9. DC靶机1-9合集

    DC1 文章前提概述 本文介绍DC-1靶机的渗透测试流程 涉及知识点(比较基础): nmap扫描网段端口服务 msf的漏洞搜索 drupal7的命令执行利用 netcat反向shell mysql的基 ...

随机推荐

  1. golang 实现冒泡排序

    package main import ( "fmt" ) func main(){ a := [...] int{2,5,9,6,8} fmt.Println(a) num := ...

  2. iptables IP流量统计

    最后是使用ipset进行流量统计,iptaccount资料太少而且还跟网上说明的操作情况不相符,继续看源码分析组长老大都不高兴.ipset使用帮助 1. 创建ipset集合:ipset create ...

  3. 蓝牙学习(3) Linux kernel部分Bluetooth HCI分析

    在上文,https://blog.csdn.net/feiwatson/article/details/81712933中主要理解了在Kernel中USB adapter是如何实现USB设备驱动,以及 ...

  4. 我的Python分析成长之路2

    2018-12-29 一.python数据类型: 1.数字 int(整形) float(浮点型) complex(复数型) 2.布尔值(bool)     真或假 True or False 3.字符 ...

  5. Java面试——HashCode的作用原理和实例解析

    ,也就是说,我们先通过 HashCode来判断两个类是否存放某个桶里,但这个桶里可能有很多类,那么我们就需要再通过 equals 在这个桶里找到我们要的类. 请看下面这个例子 : public cla ...

  6. H5系列之History(必知必会)

    H5系列之History(必知必会)   目录 概念 兼容性 属性 方法 H5方法       概念     理解History Api的使用方式 目的是为了解决哪些问题   作用:ajax获取数据时 ...

  7. Wp8 读取手机信息

    /// <summary> /// 获取系统信息 /// </summary> private void GetSystemInfo() { lblMsg.Text = str ...

  8. OmniGraffler软件和激活码

    mac上用户画图的软件:OmniGraffler破解方法 1.激活码 Name: Appked SN: MFWG-GHEB-HYTW-CGHT-CSXU-QCNC-SXU 2.软件连接 链接: htt ...

  9. 在java中使用dom4j解析xml

    创建xml文档并输出到文件 import java.io.File; import java.io.FileOutputStream; import org.dom4j.Document; impor ...

  10. Android ScrollView嵌套GridView导致GridView只显示一行item

    Android ScrollView嵌套GridView导致GridView只显示一行item Android ScrollView在嵌套GridView时候,会导致一个问题发生:GridView只显 ...