This question already has an answer here:
- What does the comma operator , do? 8 answers
You see it used in for loop statements, but it's legal syntax anywhere. What uses have you found for it elsewhere, if any?
This question already has an answer here:
You see it used in for loop statements, but it's legal syntax anywhere. What uses have you found for it elsewhere, if any?
Two killer comma operator features in C++:
a) Read from stream until specific string is encountered (helps to keep the code DRY):
b) Write complex code in constructor initializers:
The Boost Assignment library is a good example of overloading the comma operator in a useful, readable way. For example: