c - Associativity interpretation? -


in c operators left-associative , right associative, left-associative operator example starts left side , ends on right of user.

if example in case of assignment operator x=y; x=5 , y=20, saying put value of y in x, seems legitimate.

but in cases if(x>y), '>` operator has left associativity. means computes is x greater y? false.

but, why go can reading right associativity is y smaller x? false

why use left associativity when output comes same in both cases?

for ternary operation mat says.

the answer x>y>z depends on direction, answer vary right left , left right. because of different comparisons done @ different stage.

both answers evaluate value, why chose 1 left associativity

the associativity concept come in play when expression has more 1 operator. property of operator in expression, not operands. define how brackets inserted, not operator means.

operator       : r expression     : x r y r z left right  : (x r y) r z right left  : x r (y r z) 

edit: reference of operator associativity in c


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -