条件在C左值和右值 [英] Condition for lvalues and rvalues in C
问题描述
下面是一些定义我读到左值
Here are the few definitions I read about lvalues
-
防爆pressions可与与放大器使用;运营商。即如果及(前pression)是不是一个错误,那么前pression是一个左值
Expressions which can be used with & operator. i.e if &(expression) is not an error, then the expression is an lvalue
防爆pression导致不属于临时对象
Expression which results in objects that are not temporary
左值前pressions可以同时在RHS和LHS的使用=运算符
lvalue expressions can be used on both RHS and LHS of = operator
右值前pressions只能在RHS中使用
rvalue expressions can be used only on RHS
请改正如有错误
这里的问题
我看了++ x是一个左值而x ++是一个rvalue
I read ++x is a lvalue and x++ is an rvalue
int i = 0;
printf("%p",(void*)&++i);
如果是这样,为什么这是一个错误?
If so, why is this an error?
如果左值前pressions可以在LHS使用
If lvalue expressions can be used on lhs
int i = 0;
++i = 10;
为什么我不能用上面的语句??两者都导致错误上面
Why can't I use the above statement??Both the above are resulting in errors
更新:以上两种语句罚款C ++
推荐答案
++我
是左值
只在 C ++ 在 C 这是一个右值
(所谓的的前pression值 C标准),不能进行分配。
++i
is an lvalue
only in C++, in C it's an rvalue
(called value of an expression in the C standard) which cannot be assigned.
这篇关于条件在C左值和右值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!