Unfamiliar Basic C++ Code
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/795286/what-does-do-in-c">What does &#39;?&#39; do in C++?</a>  </p>
</blockquote>



<pre><code>xo = ((temp.npieces%2)==1)? 1 : 2;
</code></pre>

<p>I can't figure out what this means in it's entirety. </p>

<p>xo is an integer (I think simply determining the difference between a naught and a cross) </p>

<p>temp is an instance of position which stores information about a naughts and crosses board (positions on the board of the naughts and crosses, the state of the game (i.e. whether it has been won, lost, or is undecided), and the number of pieces placed so far upon the board </p>

<p>npieces stores the number of pieces placed so far </p>

<p>%2 is obviously determining the remainder of npieces divided by 2, in order to determine whether this is odd or even, and thus whether naughts or crosses plays next</p>

<p>It's the piece at the end that confuses me, the <code>? 1 : 2</code> bit, I'm sure I've seen this or things like this before, but I'm afraid I'm not sure what this does. I know this is likely pretty basic stuff, but I was quite ill in my first year of University (I'm in my second year now) and missed odd fragments so I have irritatingly random, often embarassing, gaps in my knowledge.</p>

<p>(This is part of a mass of code for an assignment I'm working on - trying to make sense of a few hundred lines of code, this included. As this is an assignment, I am <em>more</em> than happy not to be told exactly what this line means - and indeed just to be pointed in the direction of a resource that explains <code>? 1 : 2</code> so that I can work it out for myself. Either an online resource, or a larger chapter in any textbook available in Safari Books Online would be very helpful, or, of course, a very brief explanation here.)</p>

<p>Thanks. </p>

<p>And my apologies for the un-specific question title, without knowing what the unfamiliar code does or is called, I couldn't think of a better way to phrase it. </p>
