This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Inherite from template witth gcc 3.4
- From: Laurent Marzullo <marzullo at la-defense dot oilfield dot slb dot com>
- To: gcc-help at gcc dot gnu dot org
- Date: Wed, 09 Jun 2004 12:07:30 +0200
- Subject: 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