This code produces an error in the GNU compiler:
class A
{
public:
int X;
};
template<class T>
class Foo : public T
{
public:
void doStuff();
};
template<class T>
void Foo<T>::doStuff()
{
X++;
}
There is already an answer for why this is an error. I would like to know if there is another way of working around this error rather than using
T::X
every time I want to reference the X member. I tried this:
template<class T>
void Foo<T>::doStuff()
{
using T::X;
X++;
}
But GCC gives an error: "a class-qualified name is not allowed"