C语言深度解析笔记2:操作符
来源:互联网 发布:七灯军团戒指淘宝 编辑:程序博客网 时间:2024/05/18 01:07
一、C语言运算符优先级
::
Scope resolutionLeft-to-right++
--
Suffix/postfix increment and decrement()
Function call[]
Array subscripting.
Element selection by reference−>
Element selection through pointer++
--
Prefix increment and decrementRight-to-left+
−
Unary plus and minus!
~
Logical NOT and bitwise NOT(type)
Type cast*
Indirection (dereference)&
Address-ofsizeof
Size-ofnew
,new[]
Dynamic memory allocationdelete
,delete[]
Dynamic memory deallocation.*
->*
Pointer to memberLeft-to-right*
/
%
Multiplication, division, and remainder+
−
Addition and subtraction<<
>>
Bitwise left shift and right shift<
<=
For relational operators < and ≤ respectively>
>=
For relational operators > and ≥ respectively==
!=
For relational = and ≠ respectively&
Bitwise AND^
Bitwise XOR (exclusive or)|
Bitwise OR (inclusive or)&&
Logical AND||
Logical OR?:
Ternary conditionalRight-to-Left=
Direct assignment (provided by default for C++ classes)+=
−=
Assignment by sum and difference*=
/=
%=
Assignment by product, quotient, and remainder<<=
>>=
Assignment by bitwise left shift and right shift&=
^=
|=
Assignment by bitwise AND, XOR, and ORthrow
Throw operator (for exceptions),
CommaLeft-to-right即顺序是:成员运算符 > 单目运算符 > 乘除运算 > 加减运算 > 移位运算 > 关系运算 > 位运算 > 逻辑运算 > 条件运算 > 赋值运算
二、注释
1、注释与代码同步,修改代码的同时修改相应的注释
2、对于全局变量、常量定义等要有详细注释
3、注释尽量用英文,因为有些编辑器不支持中文
4、数值的单位一定要注释,如时、分、秒、毫秒;千米、米、毫米
5、对于变量的范围一定要注释
6、对于函数的参数,返回值及函数功能要有注释
三、贪心法
C语言有这样一个规则,每一个符号应该包含尽可能多的字符,即所谓的贪心法。例如:
a+++b; <==> (a++) + b;
++i+++i+++i; <==> (++i) + (++i) + (++i);
- C语言深度解析笔记2:操作符
- C语言深度解析笔记1:关键字
- C语言深度解析笔记3:预处理
- C语言深度解析
- c语言深度 笔记
- C语言深度解析之一
- C语言深度剖析笔记(2)
- 《c语言深度剖析》笔记2
- 《c语言深度剖析》学习笔记2
- C语言深度解剖 笔记2
- c语言深度解剖笔记2
- 《c语言深度剖析》笔记
- C语言深度解剖笔记
- 《C语言深度剖析》笔记
- 《C语言深度解剖》笔记
- C语言深度解剖--笔记
- 《C语言深度剖析》笔记
- c语言深度解剖笔记
- 动态数组实现循环队列
- DetachedCriteria离线查询 org.hibernate.criterion.DetachedCriteria; org.hibernate.criterion.Restrictions;
- OneNote——随心所欲记事本
- iFix软件介绍
- 多线程_Thread类简介及创建线程的两种方式
- C语言深度解析笔记2:操作符
- InTouch软件介绍
- 基于单链表的链队列
- Civil War "开启时代杯"湘潭市第二届大学生程序设计大赛 优先队列多条件判断
- FTP服务器的那些事(一)——用win7自带的IIS建立FTP服务站点
- 《Red5 用户参考手册》之七:入门第六章 发布 Red5 和 入门第七章 Red5 的系统要求
- GetExitCodeThread(hThread, (PDWORD) &uSum);
- 《小米手机与泛泰A820L的分区结构对比分析-外加eMMC介绍》
- 多线程_多线程理论