Itβs just β,β β The Comma Operator -- Coral Kashri
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:
int
a, 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_t
i = 0, k = 500; i < 10; ++i, ++k) {
/*...*/
}
We can see this operator in action in the third section of thefor
statement. It evaluates the++i
and then evaluates++k
.