chipperMDW
Programmer
I know this question would be better suited to one of the more general C++ forums, but I didn't get any answers there, so I'm trying my luck here.
Say I have:
This works (and is apparently the/a correct way of doing it), but I don't understand the logic behind having the operator return a pointer.
Given:
that means:
roughly translates to:
which looks like it's missing a -> . Does another operator-> get called behind the scenes for the return value of operator-> ? If not, what exactly is going on here?
Say I have:
Code:
template< class T >
class SmartPtr
{
public:
...
T *operator->() { return ptr; }
private:
T *ptr;
};
This works (and is apparently the/a correct way of doing it), but I don't understand the logic behind having the operator return a pointer.
Given:
Code:
SmartPtr< FooStruct > p = &someFooStruct;
that means:
Code:
p->fooStructMember;
roughly translates to:
Code:
( &someFooStruct ) fooStructMember;
which looks like it's missing a -> . Does another operator-> get called behind the scenes for the return value of operator-> ? If not, what exactly is going on here?