Guest User

Untitled

a guest
Feb 21st, 2018
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.28 KB | None | 0 0
  1. class bar
  2. {
  3. public:
  4. bar(int* z)
  5. {
  6. ptr = z;
  7. }
  8. int* ptr;
  9. void change()
  10. {
  11. *ptr = *ptr + 1;
  12. }
  13. };
  14. class foo
  15. {
  16. public:
  17. int x;
  18. bar* b;
  19. foo()
  20. {
  21. x=10;
  22. b = new bar(&x);
  23. }
  24. };
  25. int main()
  26. {
  27. foo a;
  28. (a.b)->change();
  29. printf("%d\n",a.x);
  30. return 0;
  31. }
Add Comment
Please, Sign In to add comment