fineamy 发表于 2007-3-30 11:34

请问这句代码什么意思?(复合语句)

<br /><blockquote><br />incr&nbsp;=&nbsp;align&nbsp;&gt&gt&nbsp;PAGE_SHIFT&nbsp;?&nbsp;:&nbsp;1;<br /></blockquote><br />是否它等价于<br /><blockquote><br />incr&nbsp;=&nbsp;align&nbsp;&gt&gt&nbsp;PAGE_SHIFT&nbsp;?&nbsp;(align&nbsp;&gt&gt&nbsp;PAGE_SHIFT)&nbsp;:&nbsp;1;<br /></blockquote>

fineamy 发表于 2007-4-2 09:24

语句没问题,

<blockquote><br />The&nbsp;middle&nbsp;operand&nbsp;in&nbsp;a&nbsp;conditional&nbsp;expression&nbsp;may&nbsp;be&nbsp;omitted.&nbsp;Then&nbsp;if&nbsp;the&nbsp;first&nbsp;operand<br />is&nbsp;nonzero,&nbsp;its&nbsp;value&nbsp;is&nbsp;the&nbsp;value&nbsp;of&nbsp;the&nbsp;conditional&nbsp;expression.<br />Therefore,&nbsp;the&nbsp;expression<br />x&nbsp;?&nbsp;:&nbsp;y<br />has&nbsp;the&nbsp;value&nbsp;of&nbsp;x&nbsp;if&nbsp;that&nbsp;is&nbsp;nonzero;&nbsp;otherwise,&nbsp;the&nbsp;value&nbsp;of&nbsp;y.<br />This&nbsp;example&nbsp;is&nbsp;perfectly&nbsp;equivalent&nbsp;to<br />x&nbsp;?&nbsp;x&nbsp;:&nbsp;y<br />In&nbsp;this&nbsp;simple&nbsp;case,&nbsp;the&nbsp;ability&nbsp;to&nbsp;omit&nbsp;the&nbsp;middle&nbsp;operand&nbsp;is&nbsp;not&nbsp;especially&nbsp;useful.&nbsp;When&nbsp;it<br />becomes&nbsp;useful&nbsp;is&nbsp;when&nbsp;the&nbsp;first&nbsp;operand&nbsp;does,&nbsp;or&nbsp;may&nbsp;(if&nbsp;it&nbsp;is&nbsp;a&nbsp;macro&nbsp;argument),&nbsp;contain&nbsp;a&nbsp;side&nbsp;effect.&nbsp;Then&nbsp;repeating&nbsp;the&nbsp;operand&nbsp;in&nbsp;the&nbsp;middle&nbsp;would&nbsp;perform&nbsp;the&nbsp;side&nbsp;effect&nbsp;twice.<br />Omitting&nbsp;the&nbsp;middle&nbsp;operand&nbsp;uses&nbsp;the&nbsp;value&nbsp;already&nbsp;computed&nbsp;without&nbsp;the&nbsp;undesirable<br />effects&nbsp;of&nbsp;recomputing&nbsp;it.<br /></blockquote><br />This&nbsp;is&nbsp;GCC&nbsp;Extensions&nbsp;to&nbsp;the&nbsp;C&nbsp;Language&nbsp;Family

sinanjj 发表于 2011-8-14 14:18

看好lz.
页: [1]
查看完整版本: 请问这句代码什么意思?(复合语句)