当前位置:网站首页>Differences between standard library functions and operators
Differences between standard library functions and operators
2022-07-06 00:49:00 【qq_ one billion four hundred and ten million eight hundred and 】
malloc/free Why new/delete?
【 answer 】
malloc And free yes C++/C Standard library functions for languages ,new/delete yes C++ Operator . They can be used to request dynamic memory and free memory . For objects that are not internal data types , Light use maloc/free Can't meet the requirements of dynamic objects . Object to be created at the same time to automatically execute the constructor , Objects are automatically destructed before they die . because malloc/free It's a library function, not an operator , Not in compiler control , The task of executing constructors and destructors cannot be imposed malloc/free. therefore C++ Language needs an operator that can accomplish dynamic memory allocation and initialization new, And an operator to clean up and free memory delete. Be careful new/delete It's not a library function .
a key :
1. Library function is that you must have this library to call this function
2.new/delete It's the operator , So you can set the new and delete Rewrite , and malloc/free No way.

边栏推荐
- OpenCV经典100题
- Programmer growth Chapter 9: precautions in real projects
- [groovy] XML serialization (use markupbuilder to generate XML data | create sub tags under tag closures | use markupbuilderhelper to add XML comments)
- The population logic of the request to read product data on the sap Spartacus home page
- Lone brave man
- Data analysis thinking analysis methods and business knowledge -- analysis methods (II)
- Why can't mathematics give machine consciousness
- 如何制作自己的机器人
- Spark获取DataFrame中列的方式--col,$,column,apply
- STM32 key chattering elimination - entry state machine thinking
猜你喜欢

Beginner redis

MySQL storage engine

【EI会议分享】2022年第三届智能制造与自动化前沿国际会议(CFIMA 2022)

如何利用Flutter框架开发运行小程序

Ffmpeg captures RTSP images for image analysis

cf:C. The Third Problem【关于排列这件事】
![[groovy] JSON string deserialization (use jsonslurper to deserialize JSON strings | construct related classes according to the map set)](/img/bf/18ef41a8f30523b7ce57d03f93892f.jpg)
[groovy] JSON string deserialization (use jsonslurper to deserialize JSON strings | construct related classes according to the map set)

Spark AQE

MDK debug时设置数据实时更新

MCU realizes OTA online upgrade process through UART
随机推荐
Getting started with devkit
[groovy] JSON string deserialization (use jsonslurper to deserialize JSON strings | construct related classes according to the map set)
Meta AI西雅图研究负责人Luke Zettlemoyer | 万亿参数后,大模型会持续增长吗?
免费的聊天机器人API
The population logic of the request to read product data on the sap Spartacus home page
Promise
详细页返回列表保留原来滚动条所在位置
Reading notes of the beauty of programming
Browser reflow and redraw
[simple implementation of file IO]
State mode design procedure: Heroes in the game can rest, defend, attack normally and attack skills according to different physical strength values.
MDK debug时设置数据实时更新
Study diary: February 13, 2022
Yolov5、Pycharm、Anaconda环境安装
几百行代码实现一个 JSON 解析器
How to make your own robot
Free chat robot API
Arduino hexapod robot
golang mqtt/stomp/nats/amqp
STM32 key chattering elimination - entry state machine thinking