* Marc Schellens:
gcc 3.4 complains when a
derived class uses an indentifier which is
defined in the base class and the base class
is the template parameter.
eg. something like:
class B
{
protected:
int member;
};
template< class base>
class D: public base
{
public:
void aFun();
};
template< class base>
void D< base>::aFun()
{
member = 1;
}
template class D< B>;
It says then:
member undecalred (first use of this function).
Isn't that valid C++?
No, but older compilers may accept it (also, VC 7.1 accepts it).
The problem is that when seeing 'member = 1' for the first time the
compiler doesn't have the slightest cue about where 'member' comes from,
or whether it comes from anywhere.
To give it that clue you can use a 'using' statement in class D,
or you can qualify 'member' in some way, e.g. 'this.member'.
--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?