当前位置:网站首页>The difference between new and malloc
The difference between new and malloc
2022-07-02 01:42:00 【wrdoct】
new and malloc difference (8 individual )
(1)new and delete yes C++ Of keyword / Operator ,malloc And free yes c++/c The standard of language function .
(2)malloc need Explicitly specify the allocated memory size ,new Unwanted .
(3)new Operator from Free storage area Upper object Dynamic allocation Memory space , and malloc Function from Pile up Dynamic allocation of memory on .
【 notes 】 Usually through new Operator for memory request , This memory is the free storage area .
(4)new When operator memory allocation succeeds , Return object type , No type conversion required , so new Is in accordance with Type safety Sex operator ;malloc return void*, Need to pass through Cast take void* The pointer is converted to the type we need .
(5)new When the operator memory allocation fails , Throw out bad_alloc abnormal ;malloc Return when memory allocation fails NULL.
(6)new The operator There are constructors and destructors , While opening up space , The constructor of the custom object will be called to complete initialization ;malloc It will only open up space .
(7)malloc After allocating space , Can pass realloc Expand memory ;new Operator cannot expand memory again .
(8)new relative malloc Low efficiency , because new The bottom layer encapsulates malloc.
边栏推荐
- MySQL application day02
- Laravel artisan common commands
- 6-3漏洞利用-SSH环境搭建
- Exclusive delivery of secret script move disassembly (the first time)
- Android: the kotlin language uses grendao3, a cross platform app development framework
- No converter found for return value of type: class
- 浅浅了解Servlet
- Implementation of Weibo system based on SSM
- What are the skills of spot gold analysis?
- I Brief introduction of radio energy transmission technology
猜你喜欢

matlab 使用 resample 完成重采样

Learning notes 25 - multi sensor front fusion technology

【视频】马尔可夫链原理可视化解释与R语言区制转换MRS实例|数据分享

迁移云计算工作负载的四个基本策略

6-2 vulnerability exploitation - inevitable problems of FTP

电商系统中常见的9大坑,你踩过没?

PR second training
![[IVX junior engineer training course 10 papers to get certificates] 0708 news page production](/img/ad/a1cb672d2913b6befd6d8779c993ec.jpg)
[IVX junior engineer training course 10 papers to get certificates] 0708 news page production

GL Studio 5 安装与体验

How can I batch produce the same title for the video?
随机推荐
卷積神經網絡(包含代碼與相應圖解)
Docker installing Oracle_ 11g
[IVX junior engineer training course 10 papers to get certificates] 03 events and guessing numbers games
Experimental reproduction of variable image compression with a scale hyperprior
Six lessons to be learned for the successful implementation of edge coding
电子协会 C语言 1级 33 、奇偶数判断
Ubuntu20.04 PostgreSQL 14 installation configuration record
Architecture evolution from MVC to DDD
[IVX junior engineer training course 10 papers to get certificates] 0708 news page production
Error creating bean with name ‘stringRedisTemplate‘ defined in class path re
机器学习基本概念
The role of artificial intelligence in network security
matlab 使用 resample 完成重采样
Quatre stratégies de base pour migrer la charge de travail de l'informatique en nuage
城市选择器组件实现原理
The author is more willing to regard industrial Internet as a concept much richer than consumer Internet
What are the skills of spot gold analysis?
II Basic structure of radio energy transmission system
【图像增强】基于Frangi滤波器实现血管图像增强附matlab代码
[IVX junior engineer training course 10 papers] 05 canvas and aircraft war game production