| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1051 人关注过本帖
标题:free()和delete有什么区别么?
只看楼主 加入收藏
betashang
Rank: 1
等 级:新手上路
帖 子:11
专家分:0
注 册:2005-10-10
收藏
 问题点数:0 回复次数:3 
free()和delete有什么区别么?
在功能上有什么区别么?
搜索更多相关主题的帖子: delete free 
2005-10-18 17:56
lcm
Rank: 4
等 级:贵宾
威 望:13
帖 子:140
专家分:0
注 册:2005-2-4
收藏
得分:0 
//哈哈,与国际接轨了
摘要:malloc,free和new delete不能混用!
Otherwise, malloc() and free() are not to be used in C++ code because they don't support object semantics. Furthermore, the results of calling free() to release an object that was allocated by new, or of using delete to release memory that was allocated by malloc(), are undefined. The C++ standard doesn't guarantee that the underlying implementation of operator new uses malloc(); in fact, on some implementations malloc() and new use different heaps

[此贴子已经被作者于2005-10-18 22:34:45编辑过]


从 小 事 做 起,脚 踏 实 地 ~
2005-10-18 18:13
lcm
Rank: 4
等 级:贵宾
威 望:13
帖 子:140
专家分:0
注 册:2005-2-4
收藏
得分:0 
你看看这个:http://www.cndiy8.com/ask7/ask147402.htm 那里讲得很详细;

从 小 事 做 起,脚 踏 实 地 ~
2005-10-18 18:18
zinking
Rank: 7Rank: 7Rank: 7
等 级:贵宾
威 望:35
帖 子:916
专家分:0
注 册:2004-12-5
收藏
得分:0 
我通俗的说一下吧,
delete 是用在c++里的
而malloc free 则是用在c 里
而且,deletE 提供的功能要比Free强大的多阿

具体的研究就参见二三楼 的连接贴了

http://kongfuziandlife. http://codeanddesign.
2005-10-18 18:44
快速回复:free()和delete有什么区别么?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015949 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved