Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C++ Increment and Decrement Operators #6805

Closed
JankieQwQ opened this issue Feb 13, 2024 · 1 comment
Closed

C++ Increment and Decrement Operators #6805

JankieQwQ opened this issue Feb 13, 2024 · 1 comment

Comments

@JankieQwQ
Copy link

JankieQwQ commented Feb 13, 2024

In some Chinese C++ textbooks (For example: Tan Haoqiang C programming), there are often exercises like the following:

#include <iostream>

int main(){
    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.

@JankieQwQ JankieQwQ changed the title Inquiry on C++ Increment and Decrement Operators C++ Increment and Decrement Operators Feb 13, 2024
@jwakely
Copy link
Member

jwakely commented Feb 13, 2024

This repository is for editorial work on the C++ draft, not for questions about C++ or the content of the draft.

https://github.com/cplusplus/draft/wiki/How-to-submit-an-editorial-issue

I suggest you ask this somewhere like stackoverflow.com instead.

@jwakely jwakely closed this as not planned Won't fix, can't repro, duplicate, stale Feb 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants