博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
malloc() vs new
阅读量:4285 次
发布时间:2019-05-27

本文共 528 字,大约阅读时间需要 1 分钟。

轉載自 

malloc() vs new

Following are the differences between malloc() and operator new.

1) new calls constructors, while malloc() does not. In fact primitive data types (char, int, float.. etc) can also be initialized with new. For example, below program prints 10.

#include
using namespace std; int main(){ int *n = new int(10); // initialization with new() cout<<*n; getchar(); return 0;}

2) new is an operator, while malloc() is a fucntion.

3) new returns exact data type, while malloc() returns void *.

转载地址:http://wrsgi.baihongyu.com/

你可能感兴趣的文章
EMQTT的ACL鉴权(topic权限控制)
查看>>
emqx客户端用户名密码登录验证配置
查看>>
python多线程之信号量semaphore实战
查看>>
ubuntu下忘记mysql密码重置方式
查看>>
ubuntu不在python虚拟环境下使用uwsgi启动django及nginx代理配置
查看>>
flask ORM之SQLAlchemy基本架构实战
查看>>
Python2和python3中类型判断
查看>>
Centos 7上搭建flask项目实战
查看>>
搭建nginx+uwsgi+flask遇到KeyError: 'REQUEST_METHOD'
查看>>
Nginx+uwsgi+flask部署实战
查看>>
UnicodeDecodeError: 'gbk' codec can't decode byte 0xa6 in position 9737: illegal multibyte sequence
查看>>
python中导入 train_test_split提示错误
查看>>
django创建项目的一些命令
查看>>
python3.6合并多个文件代码
查看>>
python中enumerate函数实战
查看>>
python中使用shuffle和permutation对列表进行随机洗牌区别
查看>>
使用js连接mqtt
查看>>
ubuntu下mysql数据库docker的定时备份脚本
查看>>
python3基于 Doc2Vec 的电影评论分析实战
查看>>
Centos 7 下influxdb docker的安装及使用
查看>>