Why can't a C++ compiler recognize that g()
and b
are inherited members of Superclass
as seen in this code:
template<typename T> struct Superclass {
protected:
int b;
void g() {}
};
template<typename T> struct Subclass : public Superclass<T> {
void f() {
g(); // compiler error: uncategorized
b = 3; // compiler error: unrecognized
}
};
If I simplify Subclass
and just inherit from Subclass<int>
then it compiles. It also compiles when fully qualifying g()
as Superclass<T>::g()
and Superclass<T>::b
. I'm using LLVM GCC 4.2.
Note: If I make g()
and b
public in the superclass it still fails with same error.