Answer's Question about pointer
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的更多相关文章
- Stack-overflow, how to answer
How to Answer Welcome to Stack Overflow! Thanks for taking the time to contribute an answer. It's be ...
- HOW TO ANSWER: Tell Me About Yourself
https://biginterview.com/blog/2011/09/tell-me-about-yourself.html There are some job interview quest ...
- 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 ...
- 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 ...
- Learning Conditioned Graph Structures for Interpretable Visual Question Answering
Learning Conditioned Graph Structures for Interpretable Visual Question Answering 2019-05-29 00:29:4 ...
- DrQA 阅读维基百科来回答开放问题 Reading Wikipedia to Answer Open-Domain Questions
DrQA 是一个阅读理解系统用在开放领域问答.特别的,DrQA 针对一个机器阅读任务.在这个列表里,我们为一个潜在非常大的预料库中搜索一个问题的答案.所以,这个系统必须结合文本检索和机器文本理解. 项 ...
- RFID 读写器 Reader Writer Cloner
RFID读写器的工作原理 RFID的数据采集以读写器为主导,RFID读写器是一种通过无线通信,实现对标签识别和内存数据的读出和写入操作的装置. 读写器又称为阅读器或读头(Reader).查询器(Int ...
- 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 ...
- DC靶机1-9合集
DC1 文章前提概述 本文介绍DC-1靶机的渗透测试流程 涉及知识点(比较基础): nmap扫描网段端口服务 msf的漏洞搜索 drupal7的命令执行利用 netcat反向shell mysql的基 ...
随机推荐
- MySQL Group Replication(组复制MGR)
MGR基本要求: 1.InnoDB存储引擎 2.主键,每个表必须具有已定义的主键或等效的主键,其中等效项是非null唯一键 3.IPv4网络 4.网络性能 5.开启二进制日志并开启GTID模式 6.m ...
- dubbo---------timeout与retires
相信很多人都见过这张图,这张图说明了提供者与消费者之间的关系,下面就介绍一下这个图是什么意思. 1.角色解释: Provider: 暴露服务的服务提供者. Consumer: 调用远程服务的服务消费者 ...
- UNIX环境C语言进程控制
一.进程ID 进程ID即是进程标识,每一个进程都会有一个唯一的非负整数来作为它的进程ID. ID为0的进程通常是调度进程,也可称为交换进程,该进程是内核的一部分,不执行硬盘上的程序,因此也被称为系统进 ...
- Python的两个爬虫框架PySpider与Scrapy安装
Python的两个爬虫框架PySpider与Scrapy安装 win10安装pyspider: 最好以管理员身份运行CMD,不然可能会出现拒绝访问文件夹的情况! pyspider:pip instal ...
- solr DIH 设置定时索引
1 web.xml中加入 web.xml所在目录 /opt/solr-7.7.1/server/solr-webapp/webapp/WEB-INF <listener> <list ...
- 基础训练 Sine之舞
Sine之舞 #include<iostream> #include<vector> #include<string.h> using namespace std; ...
- DocView mode 2 -- 快捷键
** 启动 C-c C-c 切换DocView和文件内容显示 M-x doc-view-mode 启动主模式 M-x doc-view-minor-mode 启动辅模式 k k ...
- Python之FTP传输
访问FTP,无非两件事情:upload和download,最近在项目中需要从ftp下载大量文件,然后我就试着去实验自己的ftp操作类,如下(PS:此段有问题,别复制使用,可以参考去试验自己的ftp类! ...
- BZOJ 4001 [TJOI2015]概率论 ——找规律
题目太神了,证明还需要用到生成函数. 鉴于自己太菜,直接抄别人的结果好了. #include <map> #include <cmath> #include <queue ...
- cf287E Main Sequence
As you know, Vova has recently become a new shaman in the city of Ultima Thule. So, he has received ...