int x=2, y=10;Surprisingly, because "+y" compiles (it just means positive y), this also compiles:
x=x+y;
cout<<"x="<<x<<" and y="<<y<<"\n";
x=x + +y;And of course, "++y" means to pre-increment y:
x=x + ++y;Or, you can have a positive pre-increment on y:
x=x + + ++y;You can also post-increment x, although now we need to assign to a different variable (here, z):
int z=x++ + + ++y;This compiles perfectly, with no warnings, but frankly it looks like utter gibberish. C++ has quite a few constructs that can be abused this way, sometimes unintentionally, resulting in code that is very difficult to understand or modify.
| ||||
Options | Executing Run: netrun/safe_run.sh ./code.exe v This is the output of your program.
Finished. |