increment and decrement with cout in C++ [duplicate]
问题 This question already has answers here : Unexpected order of evaluation (compiler bug?) [duplicate] (3 answers) Closed 5 years ago . I'm new to C++ and study the increment and decrement operators. So I tried this example: int x = 4; cout << ++x << " " << x++ << " " << x++ << endl << endl; cout << x << endl; It returns this weird output on C++ .NET and QtCreator and 5 online C++ compilers: 7 5 4 7 The weird thing is that I expect something like this: 5 5 6 7 Can you explain what happens? 回答1: