当前位置:网站首页>new的多种使用方法
new的多种使用方法
2022-07-27 12:53:00 【猿饵块】
new:
1:int *p=new int (10);
开辟一个整型内存大小的地址赋给指针p,再将10赋给指针
2:int *p=new int[10];
开辟10个int型的地址,并把这10个int类型大小的地址的首地址赋给指针p
new出来的指针的释放:
delate[] array; /delate array[];
3,开辟内存的同时赋多个相同值
bool* n;
n = new bool[2]{false};
if (*n == false) cout << "false" << endl;
int *p=new int[10]();//默认初始化值为04,开辟内存的同时赋多个不同值
int *p=new int[5]{1,2,3,4,5};边栏推荐
- 双料第一!
- [2023 Fudan Microelectronics written examination questions in advance] ~ questions and reference answers
- 52: Chapter 5: developing admin management services: 5: developing [paging query admin account list, interface]; (swagger's @apiparam(), annotate the method parameters; PageHelper paging plug-in; Inte
- 期货手续费标准和保证金比例
- 利用eBPF探测Rootkit漏洞
- Final solution for high collapse (no side effects)
- 剑指Offer 07 重建二叉树 -- 从中序与后序遍历序列构造二叉树
- Absolute positioning
- Seata 在蚂蚁国际银行业务的落地实践
- 面试官常问:如何手撸一个“消息队列”和“延迟消息队列”?
猜你喜欢
随机推荐
数据库内核开发人员,值一个马克杯!!!
Differences between shell environment variables and set, env, export
How to maintain slip ring equipment
js回调函数(callback)
初学者入门:使用WordPress搭建一个专属自己的博客
[C Advanced] pointer array vs array pointer
Double material first!
eBPF/Ftrace
Tencent cloud and the China Federation of industry released the research results of industrial AI quality inspection standardization to accelerate the intelligent transformation of manufacturing indus
Seata 在蚂蚁国际银行业务的落地实践
Verilog's system tasks - $fopen, $fclose and $fddisplay, $fwrite, $fstrobe, $fmonitor
egg-swagger-doc 图形验证码解决方案
MFC FTP creates multi-level folders and uploads files to the specified directory of FTP
LeetCode报错及其解决方案
Classification and application of slip rings
附加:【URLEncoder.encode(待编码字符串, “编码方式“);】(是什么?;我们向cookie中设置值的时候,为什么要使用这个去编码?)(待完善……)
How can electric complete set enterprises do well in cost and profit management with the help of ERP system?
期货公司开户后续会有哪些服务?
Using ebpf to detect rootkit vulnerabilities
Adhesive positioning









