Consider the following code snippet:
#include <iostream>
using namespace std;
int main() {
int x = 10;
std::cout << (x++) << std::endl;
return 0;
}
I expect the x++ to be equivalent to ++x as the expression is enclosed by round brackets. And accordingly expect 11 to be printed, but the output is 10. Why?
EDIT: I understand that pre and post increment work differently, what I don't understand is that why bracket priority is ignored i.e if I say x = (a +b) * c, I expect a and b to be added first and then multiplied with c, instead of b *c and then addition with a