Is operator-> “chained” for pointers? [duplicate]
问题 Possible Duplicate: Overloading operator -> Hi, I've seen that operator->() is chained (re-applied) after it is evaluated, for example: struct Bar { Bar() : m_str("Hello world!") {} const string* operator->() const { return &m_str; } string m_str; }; struct Foo { const Bar& operator->() const { return m_bar; } Bar m_bar; }; int main() { Foo f; cout << f->c_str() << endl; return 0; } works pretty fine, which requires three operator->() to be evaluated - Foo::operator->() , Bar::operator->()