<p>How does the comma operator work in C++?</p>

<p>For instance, if I do:</p>

<pre><code>a = b, c;  
</code></pre>

<p>Does a end up equaling b or c? </p>

<p>(Yes, I know this is easy to test - just documenting on here for someone to find the answer quickly.)</p>

<p><strong>Update:</strong>  This question has exposed a nuance when using the comma operator.  Just to document this:</p>

<pre><code>a = b, c;    // a is set to the value of b!

a = (b, c);  // a is set to the value of c!
</code></pre>

<p>This question was actually inspired by a typo in code.  What was intended to be</p>

<pre><code>a = b;
c = d;
</code></pre>

<p>Turned into</p>

<pre><code>a = b,    //  &lt;-  Note comma typo!
c = d;
</code></pre>

It would be equal to
```
b
```
.
The comma operator has a lower precedence than assignment.