0
C++ special bracket usage question
cout << (1<<1); // outputs 2 Interesting. Does the () overload the << ? Or would there be a totally separate concept at play?
1 Answer
+ 2
The parentheses are there to signify that expression should be evaluated first, and that the evaluation result is the one to be inserted into the output stream. I think it also guards from problem triggered by conflict of operators.
As you may have been aware of, << is insertion operator for output stream object (std::cout), but it is also bitwise left shift operator, the mix of use of the bitwise shift left and the insertion overload may "confuse" the compiler.
Please tag your thread proportionally ...
P.S. You have accidentally created two copies of this question, kindly take one of them down to help reduce duplicate questions (you choose which)