<分区>
我知道 -->
不是运算符。它实际上是两个独立的运算符--
和>
。它与下面的操作相同。
while( (x--) > 0 )
现在我运行了两个程序,但它引起了我的一些困惑。
第一个程序:
int main(void)
{
int x = 10;
while(----x>0)
{
cout<<x<<endl;
}
}
输出: 8 6 4 2
第二个程序:
int main(void)
{
int x = 10;
while(x---->0)
{
cout<<x<<endl;
}
}
编译错误:
lvalue required as decrement operand
实际上这里发生了什么??为什么第一个程序运行成功而第二个程序运行失败??