Why is the following code not compiling?
#include <iostream>
template <class T>
class A
{
public:
T data;
};
template<typename T>
class B : public A<T>
{
public:
void foo(){printf("%d\n", data);}
};
int main()
{
B<int> b;
}
Error:
bla.cpp: In member function ‘void B<T>::foo()’:
bla.cpp:14:30: error: ‘data’ was not declared in this scope
void foo(){printf("%d\n", data);}
It seems that the member variable "data" is hidden for some reason.