You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In some Chinese C++ textbooks (For example: Tan Haoqiang C programming), there are often exercises like the following:
#include<iostream>intmain(){
int i = 1;
std::cout << (i++)+(++i) << endl;
}
The textbook provides the answer as 6, but when compiled with G++, the output is 4 or 5 or 6(Depends on level of optimization).
I want to have some specification for this operation, such as:In the same row, if the variable has been increment more than once, the value before the first increment of the variable is used as the reference value.
Thanks.
The text was updated successfully, but these errors were encountered:
JankieQwQ
changed the title
Inquiry on C++ Increment and Decrement Operators
C++ Increment and Decrement Operators
Feb 13, 2024
In some Chinese C++ textbooks (For example: Tan Haoqiang C programming), there are often exercises like the following:
The textbook provides the answer as
6
, but when compiled with G++, the output is4
or5
or6
(Depends on level of optimization).I want to have some specification for this operation, such as:In the same row, if the variable has been increment more than once, the value before the first increment of the variable is used as the reference value.
Thanks.
The text was updated successfully, but these errors were encountered: