| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 371 人关注过本帖
标题:关于operator new
只看楼主 加入收藏
specilize
Rank: 4
等 级:业余侠客
帖 子:126
专家分:247
注 册:2011-2-20
结帖率:100%
收藏
已结贴  问题点数:0 回复次数:1 
关于operator new
假设我要分配50个int对象,那我可以这样写
void* buffer operator new(50*sizeof(int));
也可以这样写
void* buffer operator new[](50*sizeof(int));
这两种方法除了delete时应使用相应的形式外,到底有什么其他的不同的
2011-06-28 17:23
rjsp
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:版主
威 望:528
帖 子:9007
专家分:53942
注 册:2011-1-18
收藏
得分:14 
目前看来无不同,但我帮你google了一下

Why are operator new and operator new[] different? One often wants to implement a simple new/delete for a particular class (for instance by keeping a freelist) while not worrying about cases where one must allocate different-sized chunks of memory. Defining operators new and delete for a class but not new[] and delete[] accomplishes exactly this.
http://www.scs.stanford.edu/~dm/home/papers/c++-new.html
2011-06-29 08:46
快速回复:关于operator new
数据加载中...
 
   



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

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