We all know that every ‘,’ matters in this language, so I decided to talk directly about that character today. So, how much impact can be for such a small little character?
It’s just ‘,’ – The Comma Operator
by Coral Kashri
From the article:
This operator comes from C, where it tells the compiler to evaluate all the expressions (left to right) and to return the result of the latest evaluated expression. For example:
inta, b;a = 5, b = 4, b += a, ++a, std::cout << b <<" "<< a;// Prints 9 6
Another example of that operator usage is as follows:
for(size_ti = 0, k = 500; i < 10; ++i, ++k) {/*...*/}
We can see this operator in action in the third section of theforstatement. It evaluates the++iand then evaluates++k.

Add a Comment
Comments are closed.