When using cout and cin, what are the “<<” and “>>” operators doing and why do we use them?
问题 For example: int age; cin >> age; cout << "You are " << age << " years old!" << endl; Why do we use the "<<" and ">>" operators here? What are they doing? I somewhat understand bit-shifting, but I don't get how that works here. 回答1: They are called the stream insertion operator ( << ) and the stream extraction operator ( >> ). These are the same operators as the left and right bit shift operators (even though they have different names). The bit shift operators are overloaded, so that when the