fork download
  1. #include <iostream>
  2.  
  3. class X {
  4. private:
  5. struct B {
  6. B() { y = 2012; }
  7. int y;
  8. };
  9. B* b;
  10.  
  11. public:
  12. X() { b = new B(); }
  13. B* GetB() { return b; }
  14. };
  15.  
  16. int main()
  17. {
  18. X x;
  19. // Why do we have access to X::B here?
  20. std::cout << x.GetB()->y;
  21.  
  22. return 0;
  23. }
Success #stdin #stdout 0.01s 2856KB
stdin
Standard input is empty
stdout
2012