What does ? do here?

It is sometimes called the Elvis operator, and the colon is part of it.

a?b:c ;

basically means,
If a is true then the result is b, otherwise the result is c.
?: is a ternary operator (meaning that it takes three operands), possibly the only one in C/C++.

Why is it called the Elvis operator? Because if you look at it sideways and squint a lot, you may see Elvis Presley.