0
What does ^ operator do in c++?
and if any library should we include to use this operator?
4 Réponses
+ 4
@WINTER
^ is the XOR operator in C++, just like @Dennis explained. It calculates powers only in a calculator.
But, if you want to use it to calculate powers, you must overload it...
+ 2
It's the bitwise exclusive operator, or XOR.
Bits that are the same become 0, bits that are not the same become 1
15 = 1111
6 = 110
_________
9 = 1001
+ 1
is any shortcut technique to do that like other bitwise operators have
+ 1
cout << ( 15 ^ 6 ) << endl; //XOR, 9
cout << ( 15 | 6 ) << endl; //Or, 15
cout << ( 15 & 6 ) << endl; //And, 6