fork(1) download
  1. #include <iostream>
  2.  
  3. void point_to_same_location(int* const & pt1, int*& pt2)
  4. {
  5. pt2= pt1;
  6. }
  7.  
  8. int main()
  9. {
  10. int i1= 0;
  11. int i2= 0;
  12. int i3= 0;
  13. int* pt1= &i1;
  14. int* pt2= &i2;
  15. int* pt3= &i3;
  16.  
  17. std::cout << "pt1=" << pt1
  18. << " pt2=" << pt2
  19. << " pt3=" << pt3
  20. << std::endl;
  21.  
  22. point_to_same_location(pt1, pt2);
  23. point_to_same_location(pt2, pt3);
  24.  
  25. std::cout << "pt1=" << pt1
  26. << " pt2=" << pt2
  27. << " pt3=" << pt3
  28. << std::endl;
  29. }
Success #stdin #stdout 0s 15232KB
stdin
Standard input is empty
stdout
pt1=0x7ffc4f4b91f4 pt2=0x7ffc4f4b91f8 pt3=0x7ffc4f4b91fc
pt1=0x7ffc4f4b91f4 pt2=0x7ffc4f4b91f4 pt3=0x7ffc4f4b91f4