in this code :
finalgrade = (grade > 90) ? "high pass" : (grade < 60) ? "fail" : "pass";
A book says the the ?: operator is right associative. I did an internet search so I understand what associativity means. But I can't really understand what it means for the code above. C++ starts by doing what? This operation should be left associative because it should start in the left, doing the first condition, and continue by doing the second condition if necessary, not the other way around.
If
?:
was left associative, the statementwould be treated as
which (in this case) would not compile, since
"high pass"
and(grade < 60)
have different types.Since it is actually right associative, the statement is treated as