C語言中的前置 和後置 返回的都是右值嗎?

時間 2021-05-12 17:20:05

1樓:w2014

以C99為例,並沒有找到直接解釋這個問題的描述。

但是在6.5.16 Assignment operators

中有這樣的描述

An assignment operator stores a value in the object designated by the left operand. An assignment expression has the value of the left operand after the assignment, but isnot an lvalue.

而另一方面,在

6.5.3.1 Prefix increment and decrement operators

中,又有這樣的描述

The expression ++E is equivalent to (E+=1).

所以…看起來前置++確實是右值

當然,在cppreference上我們也找到了這樣的表述:

For non-boolean operands, the expression ++x is exactly equivalent to x+=1, and the expression --x is exactly equivalent to x-=1, that is, the prefix increment or decrement is anlvalueexpression that identifies the modified operand.

The operand expr of a built-in postfix increment or decrement operator must be a modifiable (non-const) lvalue of non-boolean(since C++17) arithmetic type or pointer to completely-defined object type. The result isprvaluecopy of the original value of the operand.

所以,我感覺您說的是對的。

C語言中,break和continue都是跳出迴圈,有啥區別?

兵長喵w 一般這個年齡段都不會長久,非常困難 你們要面對的困難是 1.不小心偷嘗禁果導致懷孕 你們這個年紀,女生還好,男生16歲開始就會想做那種事情,最好是克制,畢竟這個對未成年人的身體發育是有影響的,不是未成年該做的事,留到十八歲以後或者結婚再做,否則後果不堪設想,就算用了tao也還是會有一點懷孕...

請問c語言中的 的返回值是什麼?

暮無井見鈴 一段時間內 都是。至少在 C99 C17 中,true 就是 int 型別的 1 不過在 C23 1 中改掉了。true 變成了 Bool 1u 型別變成了 Bool 而在預處理環境中表現為無符號整數。 邱昊宇 是 int 型的 0 或者 1 The equal to and not e...

怎樣生動的理解C語言中的返回值return?

醉臥沙場 知道C語言的返回值是什麼並不難,它一般只是乙個儲存在約定暫存器 比如eax 中返回給呼叫函式讀取的數值而已。但是如果你需要了解整個函式呼叫以及返回的過程,才能對其有更全面的理解。我給很多人解釋過函式呼叫和返回的事情了,所以這裡不再過多贅述細節。有興趣的話可以看我為此寫的系列文章 醉臥沙場 ...