Why can operator-> be overloaded manually?

Posted by FredOverflow on Stack Overflow See other posts from Stack Overflow or by FredOverflow
Published on 2010-05-30T12:11:10Z Indexed on 2010/05/30 12:22 UTC
Read the original article Hit count: 193

Wouldn't it make sense if p->m was just syntactic sugar for (*p).m? Essentially, every operator-> that I have ever written could have been implemented as follows:

Foo::Foo* operator->()
{
    return &**this;
}

Is there any case where I would want p->m to mean something else than (*p).m?

© Stack Overflow or respective owner

Related posts about c++

Related posts about pointers