int p = 1; int q = 2; cout << "p = " << p << " q = " << q << endl; swap(p, q); cout << "p = " << p << " q = " << q << endl;
produces the following output: p = 1 q = 2 p = 2 q = 1
p = 1 q = 2 p = 2 q = 1