Pete wrote in news:AsPLc.48097$y04.21385@fe2.news.blueyonder.co. uk in
comp.lang.c++:
[color=blue]
> If anyone here can tell me what's going wrong in this snippet, I'd be
> much obliged. It works under g++ 3.3 but not the (fussier) g++ 3.4.
> Thanks...
>
>[/color]
The name m_x from the base 'base< T >' is dependant on the template
argument 'T', you need to tell a conforming compiler (g++ 3.4 in this
case) that 'm_x' is in 'base< T >' otherwise it will assume its a global.
[color=blue]
>
> template<typename T>
> struct base
> {
> T m_x;
> };
>
> template<typename T>
> struct derived : public base<T>
> {[/color]
Fix 1:
using base< T >::m_x;
[color=blue]
> void bleh();
> };
>
> template<typename T>
> void derived<T>::bleh()
> {[/color]
Fix 2:
[color=blue]
> T b = base<T>::m_x; // OK
> T a = m_x; // error: `m_x' undeclared[/color]
Fix 3:
T c = this->m_x;
[color=blue]
> }
>[/color]
Note that Fix 1 puts a requirement on derived< T > that the
instansiated specialization for 'base< T >' contains a non-type
member m_x, Fix 2 and 3 only make this requirement if
derived< T >::bleh() is instantiated.
HTH.
Rob.
--
http://www.victim-prime.dsl.pipex.com/