What do you mean from left to right associativity in this case?

I read about the <operator in C ++ from C ++ Primer.
It has some lines written about <Operator

cout <"Some string" is evaluated by the left-hand operator, the result of which is the cout object itself. (We say that the operator is associated from left to right).

It would be great if someone explains what these lines mean.

+3
source share
2 answers

From left to right, associativity means that the expression is implicitly enclosed in brackets:

(((cout << "foo") << "bar") << "baz")

In other words, the left-most operation comes first.

In contrast, assignment in all languages ​​is right-associative:

a = b = c + 5;

c + 5 "a", "b", .

+3

,

cout << a << b

(cout << a) << b

not

cout << (a << b)

: cout << a a, cout, (cout << a) << b. , - , , .

+4

All Articles