Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. // Forward declare the inner class
  2. class inner;
  3.  
  4. // The actual outer class.
  5. class outer {
  6. public:
  7.  
  8. // This is the function you would like to call.
  9. int get_data();
  10.  
  11. private:
  12. inner _inner;
  13. }
  14.  
  15. // The actual definition of the inner class.
  16. class inner {
  17. public:
  18. inner(outer& o) : _outer(o) // Set the reference.
  19. {
  20.  
  21. }
  22.  
  23. // The function using the data in outer.
  24. void do_stuff()
  25. {
  26. int x = _outer.get_data() + 5;
  27. }
  28.  
  29. private:
  30. // A reference to the outer class.
  31. outer& _outer;
  32.  
  33. }
  34.  
  35. __this = (outer*)((unsigned long long)this - (unsigned long long)(&((outer*)0)->inner_instance));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement