fork download
  1. class HugeClass
  2. {
  3. public:
  4. struct memberspace
  5. {
  6. int f() const { return parent.f; }
  7.  
  8. private:
  9. friend HugeClass;
  10. explicit memberspace(HugeClass & parent)
  11. : parent(parent) {}
  12. HugeClass & parent;
  13. } memberspace;
  14.  
  15. HugeClass() : memberspace(*this), f(42) {}
  16.  
  17. private:
  18. int f;
  19. };
  20.  
  21. int main()
  22. {
  23. HugeClass c;
  24. c.memberspace.f();
  25. return 0;
  26. }
Success #stdin #stdout 0s 2848KB
stdin
Standard input is empty
stdout
Standard output is empty