0

What does ^ operator do in c++?

and if any library should we include to use this operator?

1st Apr 2017, 1:04 PM
suyash ajmera
suyash ajmera - avatar
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...
1st Apr 2017, 1:36 PM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
+ 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
1st Apr 2017, 5:29 PM
Dennis
Dennis - avatar
+ 1
is any shortcut technique to do that like other bitwise operators have
1st Apr 2017, 1:25 PM
suyash ajmera
suyash ajmera - avatar
+ 1
cout << ( 15 ^ 6 ) << endl; //XOR, 9 cout << ( 15 | 6 ) << endl; //Or, 15 cout << ( 15 & 6 ) << endl; //And, 6
1st Apr 2017, 1:31 PM
Dennis
Dennis - avatar