Can someone explain how exactly this works step by step (how in the end y
becomes x
and x
becomes y
)?
#include <iostream>
using namespace std;
int main()
{
int x, y;
x = 2; y = 3;
x ^= y ^= x ^= y; // <- how this line exactly works?
cout << x << ' ' << y << endl; //returns: 3 2
system("pause");
}
- I used this code with Visual Studio 2015 Update 1