On czwartek 27 marzec 2003 07:00 pm, Angus Leeming wrote:
> On Thursday 27 March 2003 11:55 pm, John Levon wrote:
> > On Thu, Mar 27, 2003 at 11:42:29PM +0000, Angus Leeming wrote:
> > > template <class T>
> > > class B : public T
> > > {
> > > public:
> > >         void foo()
> > >         {
> > >         if (emergency_exit)
> > >                 ...
> > >         }
> > > };
> > >
> > > >  And how would "this->" assist in telling the
> > > > compiler that it is from the base class (as opposed to the derived
> > > > class)?
> > >
> > > It says that it's a member. Since it's not in B, it has to be in T.
> >
> > I don't get it, why does the compiler need the this-> hint at all ?
> >
> > I'm sure he is right but I still don't understand it intuitively.
>
> Me neither and nor, it would appear do the folks on comp.lang.c++. Point
> your news reader there and have a look at the thread
>       Why is "this->member_variable" better code than "member_variable"?
> It's evolving all the time...

I guess that for all practical matters it's all about whether one wants to 
refer to member variables as

m_emergencyExit // m_ prepended

or as

this->emergencyExit

I guess getting rid of m_blah pollution (in case of my own code, at least) 
from the class declaration might be useful. But then this-> vs m_ is four 
more keystrokes. Might not make any real-life difference, though.

Cheers, Kuba Ober

Reply via email to