返回   cpper编程论坛 > 技术杂烩
注册账号 论坛帮助 会员列表 日历事件 搜索 今日新帖 标记版面已读

技术杂烩 找不到地方的技术问题?这里!

回复
 
LinkBack 主题工具 显示模式
  #1 (permalink)  
旧 2002-10-09
初级会员
 
注册日期: 2002-10-08
帖子: 13
newbie 正向着好的方向发展
默认 j=*p++ 和 j=*p;p++ 这两个语句意思是相同的吗?

j=*p++ 和 j=*p;p++ 这两个语句意思是相同的吗?

它们可以互相代替吗,你们平时喜欢用哪句?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
回复时引用此帖
  #2 (permalink)  
旧 2002-10-09
polyrandom 的头像
超级版主
 
注册日期: 2002-09-03
帖子: 3,138
文章: 20
polyrandom 正向着好的方向发展
默认

一般来说意义相同,而且前者更加简洁。
但是,某种意义上来说,后者可以保证不会错。前者在某些特殊情况下(一般除非你故意,不会碰到),会有问题。
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
回复时引用此帖
  #3 (permalink)  
旧 2002-10-09
初级会员
 
注册日期: 2002-10-08
帖子: 13
newbie 正向着好的方向发展
默认

谢谢popa大虾
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
回复时引用此帖
  #4 (permalink)  
旧 2002-10-10
lonelywhisper 的头像
高级会员
 
注册日期: 2002-09-25
帖子: 111
lonelywhisper 正向着好的方向发展
发送 MSN 消息给 lonelywhisper
默认

效率上应该有细微的差别。我只使用后一种形式,我觉得code不仅仅是给自己看的,当然,这句代码不会有太多迷惑人的地方,但是恐怕会养成过于追求效率而忽视可读性的不良习惯。
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
回复时引用此帖
  #5 (permalink)  
旧 2002-10-10
abp 的头像
abp abp 当前离线
高级会员
 
注册日期: 2002-08-30
帖子: 811
abp 正向着好的方向发展
默认

效率上为什么会有差别?
不过q=*p++某些情况下不安全倒是真的。
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
回复时引用此帖
  #6 (permalink)  
旧 2002-10-10
lonelywhisper 的头像
高级会员
 
注册日期: 2002-09-25
帖子: 111
lonelywhisper 正向着好的方向发展
发送 MSN 消息给 lonelywhisper
默认

在我印象中,前者比后者效率稍高(编译优化的存在,曾有帖子讨论过该问题,可能有出入),安全性我倒是没有关注过。
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
回复时引用此帖
  #7 (permalink)  
旧 2002-10-10
abp 的头像
abp abp 当前离线
高级会员
 
注册日期: 2002-08-30
帖子: 811
abp 正向着好的方向发展
默认

没有,如果都是后缀的++,效率应该是一样的。
前面那个等式,如果q是*p的reference,就会有问题的。
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
回复时引用此帖
回复

书签

主题工具
显示模式

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

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



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


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

Search Engine Friendly URLs by vBSEO 3.1.0