template<typename T> class A {
protected:
int member;
};
template<typename T> class B : public A<T> {
B() {
member = 12;
}
};
When I try to compile the above program, I get:
test.cpp: In constructor ‘B<T>::B()’:
test.cpp:8:9: error: ‘member’ was not declared in this scope
member = 12;
^~~~~~
I know how to solve the problem. I just change member=12
to this->member=12
. My question is: why does the compiler not compile this?
I'll point out that the error is issued despite the fact that the template have not been instantiated in any way. It's just two classes defined, still in template form.