Why does postfix operator++ have higher precedence than prefix operator++?

前端 未结 3 1965
感动是毒
感动是毒 2021-01-04 09:42

Defined this way, we can do neither ++x++ nor ++x--. But on the other hand, both (++x)++ and (++x)-- are useful expressio

3条回答
  •  心在旅途
    2021-01-04 10:07

    C++ standard just kept the C rules and obviously those weren't fixed considering operator overloading and idioms yet be invented in a yet to be invented language.

    Looking at what is available in D.M. Ritchie Home Page, on see that this precedence is already present in B (Unary operators are bound right to left. Thus -!x++ is bound -(!(x++)) in Users' Reference to B) and I didn't see increment operators in BCPL.

提交回复
热议问题