How can one Overload Operators << and >> ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 7

How can one Overload Operators << and >> ?

3rd Dec 2016, 2:46 AM
Devendra Sanghavi
Devendra Sanghavi - avatar
2 Answers
0
Here is a simple example of turning a bitwise << into a + operator. https://code.sololearn.com/c4j07QdkvFLA/#cpp From "More On Classes, Operator Overloading", "Operators that can't be overloaded include :: | .* | . | ?: "
26th Dec 2016, 9:55 PM
Candelario Eguia
Candelario Eguia - avatar
- 1
This operators are said to be bitwise operators and are listed among the many which cannot be overloaded. So, the language does not permit to overload this operators, doing which would result into an 'Compiler' error. The other operators which cannot be overloaded are ' . ' , ' : ? ' , etc. Please do hit 'like', if you find the answer helpful!
3rd Dec 2016, 6:30 PM
Rahul Soni
Rahul Soni - avatar