How do Prefix (++x) and Postfix (x++) operations work?
问题 Can someone tell me how prefix / postfix operators really work? I've been looking online a lot but haven't found anything. From what I can tell prefex first increments, then does the operation and then assigns. Postfix would do the operation first, then assign and then increment. But I'm having a bit of trouble with my code: int x, y; x = 1; y = x + x++; // (After operation y = 2)(x=2) However when I do: y = x++ + x; // (After operation y = 3)(x=2) I'm not sure why these operations would be