fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class A {
  5. public:
  6. int foo;
  7. };
  8.  
  9. void update(A& bar) {
  10. bar.foo = 10;
  11. }
  12.  
  13. void updateP(A* bar) {
  14. bar->foo = 10;
  15. }
  16.  
  17. int main() {
  18. A bay;
  19. bay.foo = 5;
  20.  
  21. update(bay);
  22. printf("bay.foo: %i\n", bay.foo);
  23.  
  24. bay.foo = 5;
  25. A* bax;
  26. bax = &bay;
  27. updateP(bax);
  28. printf("bax.foo: %i\n", bax->foo);
  29.  
  30.  
  31. return 0;
  32. }
Success #stdin #stdout 0s 3340KB
stdin
Standard input is empty
stdout
bay.foo: 10
bax.foo: 10