I get a weird error when trying to use template inheritance. This is my code:
template <class T> class A {
public:
int a {2};
A(){};
};
template <class T> class B : public A<T> {
public:
B(): A<T>() {};
void test(){ std::cout << "testing... " << a << std::endl; };
};
And this is the error:
error: use of undeclared identifier 'a'; did you mean 'std::uniform_int_distribution<long>::a'?
void test(){ std::cout << "testing... " << a << std::endl; }
And in case it could affect something I use these flags:
-Wall -g -std=c++11
I really don't know what is wrong since the same code as pure classes without templating works fine.
See Question&Answers more detail:os