免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
123
最近访问板块 发新帖
楼主: maxxfire
打印 上一主题 下一主题

强制类型转换的优先级是多少? [复制链接]

论坛徽章:
0
21 [报告]
发表于 2008-09-19 13:45 |只看该作者
上表从上到下,优先级由高到低。。
另外还有两个NOTE:
Note 1:
    Parentheses are also used to group expressions to force a different order of evaluation; such parenthetical expressions can be nested and are evaluated from inner to outer
Note 2:
    Postfix increment/decrement have high precedence, but the actual increment or decrement of the operand is delayed (to be accomplished sometime before the statement completes execution). So in the statement  y = x * z++; the current value of z is used to evaluate the expression (i.e., z++ evaluates to z) and z only incremented after all else is done.

[ 本帖最后由 maxxfire 于 2008-9-19 13:47 编辑 ]

论坛徽章:
0
22 [报告]
发表于 2008-10-22 18:04 |只看该作者
强制类型转换可以看作一元操作符, 优先级与这些一元操作符相当:!(逻辑非) .(位取反) -(负号) ++(加1) --(减1) &(变量地址)

论坛徽章:
0
23 [报告]
发表于 2008-10-22 18:06 |只看该作者
强制类型转换可以看作一元操作符, 优先级与这些一元操作符相当:!(逻辑非) .(位取反) -(负号) ++(加1) --(减1) &(变量地址)

论坛徽章:
0
24 [报告]
发表于 2011-11-03 10:38 |只看该作者
(Type*)p->a;

void * pData;//pData是存在的一块儿已知内存

((TYpe*)pData)->a;
这样就可以对任意指针 扣上任意结构体的形式,还能直接赋值

论坛徽章:
0
25 [报告]
发表于 2011-11-03 12:34 |只看该作者
呵呵,看来又成水了
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP