I'm trying to use a type member of a class in its child, but I'm failing. In particular, I can't understand why this code does not compile:
template <typename T>
class A {
public:
using t = T;
A() {}
};
template <typename T>
class B: public A<T> {
public:
B() : A<T>() {}
A<T>::t foo(A<T>::t x) {
return x;
}
};
I've also tried A::t
and B::t
but none of them is working. Maybe I'm missing something on how to access inherited type members. Compiler Error:
error: need ‘typename’ before ‘A<T>::t’ because ‘A<T>’ is a dependent scope
A<T>::t foo(A<T>::t x) {
PS: I know that I could use simply T
instead of trying to access A::t
in this particular case, but the question is still valid.