Today, I noticed that it is possible to do something like this (C++):
int x = 3;
++++x; // Correct!
----x; // Correct, too!
++++++x; // x is now 6
That means we can put as many as pre-increments and pre-decrements together. Am I right? I know it will not be a good practice, however, should we use it or for example, does ++++x
perform better than x += 2
?
By the way, it is impossible to use post-increments and post-decrements in that way:
int x = 3;
x++++; // Error
x----; // Error
Why?
And my last question is, why it doesn't work in C#, Java, JavaScript, PHP or even C? (Note: I don't say Python and Ruby because they have none of postfix/prefix increment/decrement operators)
Thanks in advance!