fork(4) download
  1. #include <iostream>
  2.  
  3. void swapPointers(double*& num1, double*& num2) {
  4. double* temp = num1;
  5. num1 = num2;
  6. num2 = temp;
  7. }
  8.  
  9. int main() {
  10. double a = 1.0f;
  11. double b = 5.0f;
  12. double* pa = &a;
  13. double* pb = &b;
  14. swapPointers(pa, pb);
  15. std::cout << *pa << " " << *pb << std::endl;
  16. std::cout << a << " " << b << std::endl;
  17. }
Success #stdin #stdout 0.01s 2680KB
stdin
Standard input is empty
stdout
5 1
1 5