Inherite from template witth gcc 3.4

Laurent Marzullo marzullo@la-defense.oilfield.slb.com
Wed Jun 9 10:29:00 GMT 2004


Hello,

Could someone explain why this do not compile anymore with GCC 3.4 ?
(and compile with 3.2)

#include <iostream>

template <typename _type>
class MyClass
{
        public:
                _type   m_value;
};

template <typename _type>
class AnotherClass      :       public  MyClass<_type>
{
    public:
        void    print( void ) const
        {
            // THE ERROR IS ON THIS LINE
            std::cerr << "m_value = "  << m_value << '\n';
        }
};

int
main( void )
{
        AnotherClass<bool>      a;
        a.print();
        return 0;
}



template.cpp: In member function `void AnotherClass<_type>::print()
const':
template.cpp:18: error: `m_value' undeclared (first use this function)
template.cpp:18: error: (Each undeclared identifier is reported only
once for each function it appears in.)

I should specify, explicitly, MyClass<_type>::m_value for the program
to compile. Why should I specify the base class for accessing this
member ?

Is there any way to go around this 'probleme' with gcc 3.4 ?
Thanks
Laurent Marzullo




More information about the Gcc-help mailing list