A question about operator precedence in CPPPrimer, why does the order of the swapped variables still end up the same?

-sharpinclude <iostream>
using namespace std;
int main()
{
    int x = 0;
    int y = 0;
    int input = 0;
    
    cout << "Input a number:" << endl;
    cin >> input;

    input ? PPy, PPx : --x, --y;
    cout << "x = " << x << endl;
    cout << "y = " << y << endl;

    return 0;
}
CPP
Dec.20,2021

PPy, PPx and PPx, PPy are the same, with , , not ; , belonging to the same sentence, no problem.


the comma operator has the lowest precedence, so the two ways are equivalent to
(input? PPx, PPy:-- x),-- y and (input? PPy, PPx:-- x),-- y
so, of course, the result is the same.


(input ? PPy, PPx : --x), --y;

this-- y is bound to be carried out. Do you understand?

Menu