samedi 30 novembre 2019

variable value, after ternary operator

I have these lines of code:

int a = 10, b = 1;
a = --b ? b : (b = -99);
        cout << "a= " << a <<  "b= " <<b<< endl;

the output gives me b=-99 as a is not equal to 0(which makes senses) but it also changes the value of a to a=-99 how?

Aucun commentaire:

Enregistrer un commentaire