When trying to access type alias in a base class from derived class, I am facing the following issue:
template <typename T>
class A {
public:
using T2 = T;
};
template <typename T>
class B: public A<T> {
public:
typename A<T>::T2 obj1; // OK
T2 obj2; // Error
};
template <typename T>
class C: public A<int> {
public:
typename A<int>::T2 obj1; // OK
T2 obj2; // OK
};
I am unable to understand why does initializing the base class with an explicit type lets us access the type alias in the base class but in the first case, it leads to an error.
Thanks in advance.