Don't understand these operators

Sorry for the very basic post, the problem is you CANT google it. im curious as to what is the ? used for in c++. when i google it, it just thinks it belongs at the end of the question and doesn't give me search results that i need. it also does not allow me to google what does >> or << mean. (i know what < or > is, but not 2 of them?)
i saw an example of >> used in an enumeration
1
2
3
4
5
6
7
8
9
10
 enum
{

	ID_IsNotPickable = 0,


	IDFlag_IsPickable = 1 << 0,

	IDFlag_IsHighlightable = 1 << 1
};

and i saw the ? used like this
 
Game->Device->getGUIEnvironment()->setFocus ( Game->guiActive ? gui.Window: 0 );

I think i've seen it in if statements also

I just have really been trying to improve my c++ and those are just 2 things that I cant research through a search engine. any help is appreciated.
I dont need to know what the ? does in that specific example, i just need to know what it does in general. same with >> or <<
? : look for ternary operator
<< >> look for bit shift operators
? : is sort of like an if/then statement, only it's an expression. A ? B : C will evaluate A. Then if A is true (or non-zero) then it evaluates B, otherwise it evaluates C. The value of the expression is the value of B or C, whichever was evaluated.

For example:
1
2
3
bool b;
// do something that sets b;
cout << "b is " << (b ? "true" : "false") << end;

This will print "bis is true" or "b is false"

Since an expression can have only one type, B and C must be the same type, or be convertable to the same type.

I use ? : frequently. In particular, instead of
1
2
3
4
5
if (condition) {
    var = expr1;
} else {
    var = expr2;
}

I usually write
var = (condition ? expr1 : expr2);

<< and >> were originally the bit shift operators in C. a << 2 takes the bits in a and shifts them all up 2 positions, filling the least significant bits with 0. For example 4 << 2 == 16. Similarly b >> 2 shifts the bits down two positions. The most significant bits are filled with zeros or replicas of the sign bit, depending on whether the original value was unsigned or signed.

But in C++ you can overload operators, so it's more frequent to see << and >> used for I/O with streams. istream >> var will read var from istream, and ostream << var will put var into ostream.
Definitely search google for the English equivalent of almost any symbol. dhayden beat me to the explanation, but if there are any other opeators you need to learn about, here is this site's reference http://www.cplusplus.com/doc/tutorial/operators/
Topic archived. No new replies allowed.