返回   cpper编程论坛 > C/CPP/TMP/GP
注册账号 论坛帮助 会员列表 日历事件 搜索 今日新帖 标记版面已读

回复
 
LinkBack 主题工具 显示模式
  #1 (permalink)  
旧 2008-07-08
初级会员
 
注册日期: 2008-06-11
帖子: 8
hzzhouqq 正向着好的方向发展
默认 delete const pointer

大家好.

下面的程序delete是否执行了呢?

int *p = new int(20) ;
const int* q = p ;

delete q ;


编译是没有错误的.

为什么允许delete pointer to const?

望高手答复...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
回复时引用此帖
  #2 (permalink)  
旧 2008-07-09
高级会员
 
注册日期: 2002-09-19
帖子: 839
文章: 7
tomato 正向着好的方向发展
默认 回复: delete const pointer

const和是否可以在堆上new/delete不抵触
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
回复时引用此帖
  #3 (permalink)  
旧 2008-07-15
bankrock 的头像
高级会员
 
注册日期: 2003-12-11
帖子: 843
文章: 7
bankrock 正向着好的方向发展
默认 回复: delete const pointer

const和内存分配释放完全两码事。内存是内存,对象是对象。
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
回复时引用此帖
回复

书签

主题工具
显示模式

发帖规则
不可以发表新主题
不可以发表回复
不可以上传附件
不可以编辑自己的帖子

启用 BB 代码
论坛启用 表情符号
论坛启用 [IMG] 代码
论坛禁用 HTML 代码
Trackbacks are 启用
Pingbacks are 启用
Refbacks are 启用


相似的主题
主题 主题作者 版面 回复 最后发表
上次发到C++ news group上去的帖子,关于new/delete的问题,没有得到我想要的答案,翻出来大伙再讨论讨论 pongba C/CPP/TMP/GP 19 2006-03-08 10:19 PM
allaboutprogram.com C++ 初学者FAQ codinggirl 技术杂烩 4 2004-03-22 11:51 AM
ABP C++ FAQ02-------------essential const codinggirl 技术杂烩 1 2003-12-18 09:59 AM
const, literal 和 编译时计算 ajoo 技术杂烩 13 2003-11-21 05:07 AM
C++中的健壮指针和资源管理【转贴】 Innocentius C/CPP/TMP/GP 1 2002-10-27 06:11 PM


所有时间均为格林尼治时间 +9。现在的时间是 11:55 AM


Powered by vBulletin® 版本 3.7.0
版权所有 ©2000 - 2008,Jelsoft Enterprises Ltd.
(C) Copy Right All Right Reserved 2001 - 2007

Search Engine Friendly URLs by vBSEO 3.1.0