This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Please, help with this scope problem (simple?)
- From: Philippe Haution <philippe_haution at yahoo dot fr>
- To: Leon Pollak <leon dot pollak at gmail dot com>, Blake Huff <stangmechanic at gmail dot com>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Tue, 9 May 2006 13:57:02 +0200 (CEST)
- Subject: Re: Please, help with this scope problem (simple?)
- Reply-to: philippe dot haution at mines-paris dot org
Hello,
I think it is a problem of two-phase name lookup which
this link should help explain :
http://gcc.gnu.org/ml/gcc-help/2004-04/msg00382.html
Regards,
PH
--- Leon Pollak <leon.pollak@gmail.com> a écrit :
> I should agree with you in the case when I should
> want to refer
> ANOTHER i (from another template parameter value).
> But in this case I
> have based class B on THE SAME value of template
> parameter. I was sure
> that this indicates very clear that I want the same
> 'i' which resides
> in A<T> instantiation...:-(
>
> On 5/9/06, Blake Huff <stangmechanic@gmail.com>
> wrote:
> > I'm pretty bad with this, but here's my guess:
> What if B had
> > multiple templates, i.e., A, C, D, and E, which
> each had their own
> > i? Compiler needs to know where to go. Someone
> else might have a
> > better technical explanation (or maybe I'm wrong
> altogether!).
> >
> > Blake
> >
> >
> > On May 9, 2006, at 6:27 AM, Leon Pollak wrote:
> >
> > > Hello, all.
> > > I shall be very thankful for the help with the
> following compilation
> > > problem. The code example is:
> > >
> > > template <typename T>
> > > class A {
> > > protected: int i;
> > > };
> > >
> > > template <typename T>
> > > class B : public A<T> {
> > > public: B() {i = 0;}
> > > };
> > >
> > > My gcc version 4.0.2 20051125 (Red Hat 4.0.2-8)
> produces:
> > > error: 'i' was not declared in this scope.
> Writing:
> > > public: B() {A<T>::i = 0;}
> > > solves the problem, but why do I need to specify
> this? Isn't it
> > > obvious?
> > >
> > > Many thanks ahead.
> > >
> > > Leon.
> >
> > Blake Huff
> > stangmechanic@gmail.com
> >
> >
> >
> >
> >
> >
> >
> >
> >
>
___________________________________________________________________________
Yahoo! Mail réinvente le mail ! Découvrez le nouveau Yahoo! Mail et son interface révolutionnaire.
http://fr.mail.yahoo.com