Can someone explain what the << in C++ exactly does? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Can someone explain what the << in C++ exactly does?

Why does there need to be a << after cout? For example when I write cout << "Hello" or << endl Why can't I just write endl; without the << before it?

18th Apr 2020, 1:44 AM
Ma D. Monk
2 Answers
+ 3
It is the insertion operator. It is use to pass arguments into the ostream cout object in this case. In other cases << is a bit shift operator, so don't be confused by its use there. http://www.cplusplus.com/reference/ostream/ostream/operator%3C%3C/
18th Apr 2020, 1:50 AM
ChaoticDawg
ChaoticDawg - avatar
+ 1
Thank you!
18th Apr 2020, 12:35 PM
Ma D. Monk