This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Inherite from template witth gcc 3.4


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



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]