I'm wondering if there is a standard way, if we are pronouncing typographical symbols out loud, for reading the <<
and >>
symbols? This comes up for me when teaching first-time C++ students and discussing/fixing exactly what symbols need to be written in particular places.
The best answer should not be names such as "bitwise shift" or "insertion", because those refer to more specific C++ operators, as opposed to the context-free symbol itself (which is what we want here). In that sense, this question is not the same as questions such as this or this, none of whose answers satisfy this question.
Some comparative examples:
#include <iostream>
as "pound include bracket iostream
bracket". int a, b, c;
as "int a comma b comma c
semicolon". if (a && b) c = 0;
as "if open parenthesis a double ampersand b close parenthesis c equals zero semicolon". So an equivalent question would be: How do we similarly read cout << "Hello";
? At the current time in class we are referring to these symbols as "left arrow" and "right arrow", but if there is a more conventional phrasing I would prefer to use that.
Other equivalent ways of stating this question:
<<
?<<
, whether being used for bit-shifts, insertion, or overloaded for something entirely new?“>>” is extraction operator because “it extract data enter by user from console or input screen to some storage location identified by variable”.
The symbol << is called insertion operation and output operator.
Saw this question through your comment on Slashdot. I suggest a simpler name for students that uses an already common understanding of the symbol. In the same way that +
is called "plus" and -
is (often) called "minus," you can call <
by the name "less" or "less-than" and >
by "greater" or "greater-than." This recalls math operations and symbols that are taught very early for most students and should be easy for them to remember. Plus, you can use the same name when discussing the comparison operators. So, you would read
std::cout << "Hello, world!" << std::endl;
as
S T D colon colon C out less less double-quote Hello comma world exclamation-point double-quote less less S T D colon colon end L semicolon.
Also,
#include <iostream>
as
pound include less I O stream greater
So, the answer to
"Professor, I don't remember how to make an insertion operator; please tell me what symbol to type."
is "Less less."
The more customary name "left/right angle bracket" should be taught at the same time to teach the more common name, but "less/greater" is a good reminder of what the actual symbol is, I think.
Chevron is also a neat name, but a bit obscure in my opinion, not to mention the corporate affiliation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With