Why pre-increment operator gives rvalue in C?

前端 未结 3 1555
春和景丽
春和景丽 2020-12-14 06:52

In C++, pre-increment operator gives lvalue because incremented object itself is returned, not a copy. But in C, it gives rvalue. Why?

3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-14 07:33

    Off the top of my head, I can't imagine any useful statements that could result from using a pre-incremented variable as an lvalue. In C++, due to the existence of operator overloading, I can. Do you have a specific example of something that you're prevented from doing in C, due to this restriction?

提交回复
热议问题