考虑为 Java 发布的 SO 问题+++ 运算符如何工作?
嗯,我明白了
- 没有像 '+++' 这样的运算符,它只是一个后缀增量,后跟一个中缀添加
- 这是对可读性的犯罪
我想知道的(只是为了好奇)如果
+++
它只是一个后缀增量,后跟一个中缀添加,而 +++
不仅仅是一个中缀添加,后跟一个前缀增量或其未定义的行为。
考虑我已经测试了以下程序
#include <iostream>
int main() {
int x = 1;
std::cout<< x+++1 << std::endl;
std::cout<< 1+++x << std::endl;
}
在 VC++、gcc 和 g++ 中,它们都符合以下事实:
'+++' its just a post-fix increment followed by an infix add
并不是
'+++' its just an infix add followed by a prefix increment