fork(2) download
  1. #include<iostream>
  2.  
  3. void poo(int **currArray)
  4. {
  5. std::cout << "currArray: " << *currArray << std::endl;
  6. int *blah = new int[5];
  7. std::cout << "blah: " << blah << std::endl;
  8. delete[] *currArray; // clean after ourselves
  9. *currArray = blah;
  10. std::cout << "currArray after switch " << *currArray << std::endl;
  11. }
  12.  
  13. int main()
  14. {
  15. int *foo = new int[5];
  16. std::cout << "foo: " << foo << std::endl;
  17. poo(&foo);
  18. std::cout << "foo after poo " << foo << std::endl;
  19. delete[] foo; // clean after ourselves
  20. }
Success #stdin #stdout 0s 4568KB
stdin
Standard input is empty
stdout
foo: 0x560b3e9ffc20
currArray: 0x560b3e9ffc20
blah: 0x560b3ea00c50
currArray after switch 0x560b3ea00c50
foo after poo 0x560b3ea00c50