New answers tagged

2

Although far from advisable (at least under normal circumstances), it's certainly possible to use operator overloading to get a compiler to accept an expression like ++i++ in C++ (getting a sane code reviewer to accept it is quite another story). #include <iostream> class DontDoThis { int v; public: DontDoThis(int init) : v(init) {} ...


14

You are misinterpreting GCC's error message: <source>:5:8: error: lvalue required as increment operand ++i++; ^ Note where the error message is pointing: the postfix++ part. The token sequence ++i++ will, by C/C++'s operator precedence rules, be interpreted as ++(i++). So the postfix++ happens first. The postfix++ operator does two ...


Top 50 recent answers are included