欢迎来到天天文库
浏览记录
ID:62074547
大小:46.50 KB
页数:10页
时间:2021-04-16
《c运算符的优先级和结合性.doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、个人收集整理勿做商业用途c/c++运算符的优先级和结合性ZZ2010—05—1815:29PrecedenceOperatorDescriptionExampleAssociativity1()[]-〉。::++—-GroupingoperatorArrayaccessMemberaccessfromapointerMemberaccessfromanobjectScopingoperatorPost—incrementPost-decrement(a+b)/4;array[4]=2;ptr->age=
2、34;obj.age=34;Class::age=2;for(i=0;i<10;i++)。..for(i=10;i>0;i--).。。lefttoright2!~++---+*&(type)sizeofLogicalnegationBitwisecomplementPre-incrementPre-decrementUnaryminusUnaryplusDereferenceAddressofCasttoagiventypeReturnsizeinbytesif(!done)。.。flags=~flag
3、s;for(i=0;i<10;++i).。。for(i=10;i〉0;--i)。.。inti=-1;inti=+1;data=*ptr;address=&obj;inti=(int)floatNum;intsize=sizeof(floatNum);righttoleft3—〉*。*MemberpointerselectorMemberpointerselectorptr-〉*var=24;obj.*var=24;lefttoright4*/%MultiplicationDivisionModulusi
4、nti=2*4;floatf=10/3;intrem=4%3;lefttoright5+-AdditionSubtractioninti=2+3;inti=5-1;lefttoright6<<>>BitwiseshiftleftBitwiseshiftrightintflags=33〈〈1;intflags=33〉〉1;lefttoright7〈〈=〉>=Comparisonless—thanComparisonless-than-or—equal—toComparisonif(i<42)...if(i
5、<=42)..。if(i〉42)。。。if(i>=lefttoright个人收集整理勿做商业用途greater-thanComparisongeater-than—or—equal-to42)。.。8==!=Comparisonequal—toComparisonnot—equal—toif(i==42)。。.if(i!=42)...lefttoright9&BitwiseANDflags=flags&42;lefttoright10^BitwiseexclusiveORflags=flags^42;l
6、efttoright11
7、Bitwiseinclusive(normal)ORflags=flags
8、42;lefttoright12&&LogicalANDif(conditionA&&conditionB)。。.lefttoright13|
9、LogicalORif(conditionA
10、
11、conditionB)..。lefttoright14?:Ternaryconditional(if—then—else)inti=(a>b)?a:b;righttoleft15=+=—=*=/=%=&=^=|=<
12、<=〉>=AssignmentoperatorIncrementandassignDecrementandassignMultiplyandassignDivideandassignModuloandassignBitwiseANDandassignBitwiseexclusiveORandassignBitwiseinclusive(normal)ORandassignBitwiseshiftleftandassignBitwiseshiftrightandassigninta=b;a+=3;b-=4
13、;a*=5;a/=2;a%=3;flags&=new_flags;flags^=new_flags;flags|=new_flags;flags〈〈=2;flags〉〉=2;righttoleft16,Sequentialevaluationoperatorfor(i=0,j=0;i〈10;i++,j++)...lefttoright个人收集整理勿做商业用途在使用C语言中,由于运算符优先级而引发的错误既常见又难以发觉。我们常武断地使用了错误
此文档下载收益归作者所有