欢迎来到天天文库
浏览记录
ID:8964829
大小:41.50 KB
页数:2页
时间:2018-04-13
《c运算符优先级与结合性》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库。
1、PrecedenceOperatorDescriptionExampleAssociativity1()[]->.::++--GroupingoperatorArrayaccessMemberaccessfromapointerMemberaccessfromanobjectScopingoperatorPost-incrementPost-decrement(a+b)/4;array[4]=2;ptr->age=34;obj.age=34;Class::age=2;for(i=0;i<10;i++)...for(i=10;i>0;i--)...lefttorigh
2、t2!~++---+*&(type)sizeofLogicalnegationBitwisecomplementPre-incrementPre-decrementUnaryminusUnaryplusDereferenceAddressofCasttoagiventypeReturnsizeinbytesif(!done)...flags=~flags;for(i=0;i<10;++i)...for(i=10;i>0;--i)...inti=-1;inti=+1;data=*ptr;address=&obj;inti=(int)floatNum;intsize=s
3、izeof(floatNum);righttoleft3->*.*MemberpointerselectorMemberpointerselectorptr->*var=24;obj.*var=24;lefttoright4*/%MultiplicationDivisionModulusinti=2*4;floatf=10/3;intrem=4%3;lefttoright5+-AdditionSubtractioninti=2+3;inti=5-1;lefttoright6<<>>BitwiseshiftleftBitwiseshiftrightintflags=3
4、3<<1;intflags=33>>1;lefttoright7<<=>>=Comparisonless-thanComparisonless-than-or-equal-toComparisongreater-thanComparisongeater-than-or-equal-toif(i<42)...if(i<=42)...if(i>42)...if(i>=42)...lefttoright8==!=Comparisonequal-toComparisonnot-equal-toif(i==42)...if(i!=42)...lefttoright9&Bitw
5、iseANDflags=flags&42;lefttoright10^BitwiseexclusiveORflags=flags^42;lefttoright11
6、Bitwiseinclusive(normal)ORflags=flags
7、42;lefttoright12&&LogicalANDif(conditionA&&conditionB)...lefttoright13
8、
9、LogicalORif(conditionA
10、
11、conditionB)...lefttoright14?:Ternaryconditional(if-then-else)inti=(a>b
12、)?a:b;righttoleft15=+=-=*=/=%=&=^=
13、=<<=>>=AssignmentoperatorIncrementandassignDecrementandassignMultiplyandassignDivideandassignModuloandassignBitwiseANDandassignBitwiseexclusiveORandassignBitwiseinclusive(normal)ORandassignBitwiseshiftleftandassignBitwiseshiftrightandassigninta=b;a+=3
14、;b-=4;a*=5;a/=2;a%=3;flags&=new_flags;flags^=new_flags;flags
15、=new_flags;flags<<=2;flags>>=2;righttoleft16,Sequentialevaluationoperatorfor(i=0,j=0;i<10;i++,j++)...lefttoright
此文档下载收益归作者所有