【发布时间】:2011-10-21 10:22:13
【问题描述】:
我有:
#include<stdio.h>
int main()
{
int a=5,b=6;
(a>b)?b=a:b=b; // Here is the error
return 0;
}
但是如果我替换:
(a>b)?b=a:b=b; // Error
with
(a>b)?(b=a):(b=b); // No-Error
我知道lvalue 是一个可以赋值的值,它与rvalue 有何不同,但为什么extra parenthesis 会有所不同。
【问题讨论】:
-
C 和 C++ 不是同一种语言。你的问题是针对 C 的。
-
是的...我知道...但是确切的代码在 C 和 C++ 中的行为相同
标签: c ternary-operator conditional-operator