Possible Duplicates:
[FAQ] Why doesn't a derived template class have access to a base template class' identifiers? Problem with protected fields in base class in c++
cannot access data member in a class template
Following code gives me compilation error. What is wrong?
struct Base {
int amount;
};
template<class T> struct D1 : public Base {
};
template<class T>
struct D2 : D1<T> {
void foo() { amount=amount*2; /* I am trying to access base class data member */ };
};
int main() {
D2<int> data;
};
test.cpp: In member function 'void D2<T>::foo()':
test.cpp:11: error: 'amount' was not declared in this scope
How to fix this?
thanks