The operator precedence tables just show the bitwise shift operators << and >>. These are the same as the output operators, right?
In fact, it just so happens that C++ overloads these same operators to mean input/output, right? This is more of a tradition than anything more strict, isn’t it?
I’m sure the origin of using
<<and>>as operators for output is to do with two things.<<and>>are not that commonly used in “regular code”. So they are available. It would be a real pain if they used operator +, -, * or /, since you couldn’t writecout + "The result is : x + y + endl;and get x + y as the output. It’s much less common than you writecout << "The result is : " << x << y << endl;– in this case, you’d have to use parenthesis:cout << "The result is : " << (x << y) << endl;The order of operator precedence is defined by the language, no matter how you use the operators – which is one reason you don’t want to use operator overload to do “strange” things in general – because it’s easy to get something you don’t really expect…