#includeusing namespace std; void swap(int& x, int& y) { x = x ^ y; y = x ^ y; x = x ^ y; } int main(void) { int x = 3; // 传递引用 int& y = x; cout << x << endl; cout << y << endl; y = 10; cout << x << endl; cout << y << endl; // 交换x,z int z = 4; swap(x, z); cout << x << endl; cout << z << endl; return 0; }



