求C中所有运算符的优先级!

021850524 2003-08-21 01:38:34
同上!
...全文
132 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
catface 2003-08-21
  • 打赏
  • 举报
回复
看到有人回复 就估计大家都说了
但是任何一本正规的C教材都有这个的啊
楼主难道没书就开始学习啊
soyan 2003-08-21
  • 打赏
  • 举报
回复
又来慢了,全被楼上的说完了
wbh0360 2003-08-21
  • 打赏
  • 举报
回复
Table Operator Precedence (从大到小)详见c++ Primer Third Edition
Operator Function Use
:: global scope ::name
:: class scope class::name
:: namespace scope namespace::name
. member selectors object.member
-> member selectors pointer->member
[] subscript variable[ expr ]
() function call name(expr_list)
() type construction type(expr_list)
++ postfix increment lvalue++
−− postfix decrement lvalue−−
typeid type ID typeid(type)
typeid run-time type ID typeid(expr)
const_cast type conversion const_cast<type>(expr)
dynamic_cast type conversion dynamic_cast<type>(expr)
reinterpret_cast type conversion reinterpret_cast<type>(expr)
static_cast type conversion static_cast<type>(expr)
sizeof size of object sizeof expr
sizeof size of type sizeof( type )
++ prefix increment ++lvalue
−− prefix decrement −−lvalue
~ bitwise NOT ~expr
! logical NOT !expr
− unary minus −expr
+ unary plus +expr
* dereference *expr
& address-of &expr
() type conversion (type) expr
new allocate object new type
new allocate/init object new type(expr_list)
new alloc/place object new (expr_list) type(expr_list)
new allocate array all forms
delete deallocate object all forms
delete deallocate array all forms
->* ptr to member select pointer->*pointer_to_member
.* ptr to member select object.*pointer_to_member
* multiply expr * expr
/ divide expr / expr
% modulo (remainder) expr % expr
+ add expr + expr
− subtract expr − expr
≪ bitwise shift left expr ≪ expr
>> bitwise shift right expr >> expr
< less than expr < expr
<= less than or equal expr <= expr
> greater than expr > expr
>= greater than or equal expr >= expr
== equality expr == expr
!= inequality expr != expr
& bitwise AND expr & expr
^ bitwise XOR expr ^ expr
| bitwise OR expr | expr
&& logical AND expr && expr
‖ logical OR expr ‖ expr
?: conditional expr expr ? expr : expr
= assignment lvalue = expr
=,*=,/=,%=,+=,-=,≪=, >>=,&=,|=,^= compound assign lvalue += expr, etc.
throw throw exception throw expr
, comma expr , expr
quick3210 2003-08-21
  • 打赏
  • 举报
回复
up
EmailTan 2003-08-21
  • 打赏
  • 举报
回复
表达式 ┃优先级
────────────────────────────╂────
()(小括号) [](数组下标) .(结构成员) ->(指针型结构成员)┃ 最高
────────────────────────────┃ ↑
!(逻辑非) .(位取反) -(负号) ++(加1) --(减1) &(变量地址)┃ │
────────────────────────────┃ │
*(指针所指内容) type(函数说明) sizeof(长度计算) ┃ │
────────────────────────────┃ │
*(乘) /(除) %(取模) ┃ │
────────────────────────────┃ │
+(加) -(减) ┃ │
────────────────────────────┃ │
<<(位左移) >>(位右移) ┃ │
────────────────────────────┃ │
<(小于) <=(小于等于) >(大于) >=(大于等于) ┃ │
────────────────────────────┃ │
==(等于) !=(不等于) ┃ │
────────────────────────────┃ │
&(位与) ┃ │
────────────────────────────┃ │
^(位异或) ┃ │
────────────────────────────┃ │
|(位或) ┃ │
────────────────────────────┃ │
&&(逻辑与) ┃ │
────────────────────────────┃ │
||(逻辑或) ┃ │
────────────────────────────┃ │
?:(?表达式) ┃ │
────────────────────────────┃ │
= += -=(联合操作) ┃ │
────────────────────────────┃ │
,(逗号运算符) ┃ 最低
Dragon132 2003-08-21
  • 打赏
  • 举报
回复
1 ()
[]
->
.
2 !
~
++
--
-
*
&
sizeof
3 *
/
%
4 +
-
5 <<
>>
6 <
<=
>
>=
7 ==
!=
8 &
9 ^
10 |
11 &&
12 ||
13 ?:
14 =
15 ,
lybapple 2003-08-21
  • 打赏
  • 举报
回复
运算符 描述
. [] () 域访问、数组下标和函数调用
++ -- - ~ ! delete new typeof void 一元运算符、返回数据类型、对象创建、未定义的值
* / % 乘、除、取模
+ - + 加、减、字符串连接
<< >> >>> 位移动
< <= > >= instanceof 小于、小于等于、大于、大于等于、instanceof
== != === !== 相等、不相等、恒等、不恒等
& 按位“与”
^ 按位“异或”
| 按位“或”
&& 逻辑“与”
|| 逻辑“或”
?: 条件
= oP= 赋值、带操作的赋值
, 多重求值
Dragon132 2003-08-21
  • 打赏
  • 举报
回复
1 初等运算符
2 单目运算符
3 算术运算符
4 关系运算符
5 逻辑运算符
6 条件运算符
7 赋值运算符
8 逗号运算符
lybapple 2003-08-21
  • 打赏
  • 举报
回复
运算符 描述
. [] () 域访问、数组下标和函数调用
++ -- - ~ ! delete new typeof void 一元运算符、返回数据类型、对象创建、未定义的值
* / % 乘、除、取模
+ - + 加、减、字符串连接
<< >> >>> 位移动
< <= > >= instanceof 小于、小于等于、大于、大于等于、instanceof
== != === !== 相等、不相等、恒等、不恒等
& 按位“与”
^ 按位“异或”
| 按位“或”
&& 逻辑“与”
|| 逻辑“或”
?: 条件
= oP= 赋值、带操作的赋值
, 多重求值

69,336

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧