fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. int a = 4, b = 5;
  7. cout << "Before assignment: a: " << a << ", b: " << b << endl;
  8. pair<int&, int&> ba(b, a);
  9. ba = make_pair(a, b); // <===: (b, a) = (a, b)
  10. cout << "After assignment : a: " << a << ", b: " << b << endl;
  11. return 0;
  12. }
Success #stdin #stdout 0s 4472KB
stdin
Standard input is empty
stdout
Before assignment: a: 4, b: 5
After assignment : a: 5, b: 4