何时使用Malloc而不是New [英] When to use Malloc instead of New

查看:206
本文介绍了何时使用Malloc而不是New的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

重复的内容:在什么情况下我应该使用malloc还是新的?

只需重新阅读此问题即可:
";新"和"malloc"和"calloc"在C ++中?

Just re-reading this question:
What is the difference between "new" and "malloc" and "calloc" in C++?

我检查了答案,但没有人回答问题:

I checked the answers but nobody answered the question:

  • 何时使用malloc而不是new?

有两个原因(我可以想到两个).
让最好的漂浮到顶部.

There are a couple of reasons (I can think of two).
Let the best float to the top.

推荐答案

想到的一对夫妇:

  • 当您需要在C ++和C之间可移植的代码时.
  • 当您在可能由C调用的库中分配内存时,C代码必须释放分配.

这篇关于何时使用Malloc而不是New的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆