C,C ++,Java和C#中的前后增量运算符行为
在发布和预增量运算符方面,C / C ++,C#和Java之间究竟有什么区别?
这就是我用VC ++ 10,Java 1.6和C#4获得的
int a = 2;
int b = a++ + a++;
int c = ++a + a++ + a++;
+-----+------+------+----+
| C | C++ | Java | C# |
+-----+-----+------+------+----+
| a | 7 | 7 | 7 | 7 |
+-----+-----+------+------+----+
| b | 4 | 4 | 5 | 5 |
+-----+-----+------+------+----+
| c | 15 | 15 | 16 | 16 |
+-----+-----+------+------+----+
温温酱
慕田峪9158850