#include <iostream>
struct A {
void Foo() { std::cout << "foo" << std::endl; }
};
struct B : A {
A* operator->() { return &a; }
A a;
};
struct C : B {
B& operator->() { return b; }
B b;
};
struct D : C {
C& operator->() { return c; }
C c;
};
int main()
{
D d;
d->Foo();
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKc3RydWN0IEEgewogICAgdm9pZCBGb28oKSB7IHN0ZDo6Y291dCA8PCAiZm9vIiA8PCBzdGQ6OmVuZGw7IH0KfTsKCnN0cnVjdCBCIDogQSB7CiAgICBBKiBvcGVyYXRvci0+KCkgeyByZXR1cm4gJmE7IH0KICAgIEEgYTsKfTsKCnN0cnVjdCBDIDogQiB7CiAgICBCJiBvcGVyYXRvci0+KCkgeyByZXR1cm4gYjsgfQogICAgQiBiOwp9OwoKc3RydWN0IEQgOiBDIHsKICAgIEMmIG9wZXJhdG9yLT4oKSB7IHJldHVybiBjOyB9CiAgICBDIGM7Cn07CgppbnQgbWFpbigpCnsKICAgIEQgZDsKICAgIGQtPkZvbygpOwp9Cg==