fork download
  1. #include <iostream>
  2.  
  3. struct A {
  4. void Foo() { std::cout << "foo" << std::endl; }
  5. };
  6.  
  7. struct B {
  8. A* operator->() { return &a; }
  9. A a;
  10. };
  11.  
  12. struct C {
  13. B& operator->() { return b; }
  14. B b;
  15. };
  16.  
  17. struct D {
  18. C& operator->() { return c; }
  19. C c;
  20. };
  21.  
  22. int main()
  23. {
  24. D d;
  25. d->Foo();
  26. }
  27.  
Success #stdin #stdout 0s 2896KB
stdin
Standard input is empty
stdout
foo