15
The following code gives me a compilation error 'value' was not declared in this scope.
template<class T>
struct Base {
int value;
};
template <class T>
struct Derived : public Base<T> {
int getValue() { return value; }
};
I find it extremely odd that
- if
Derivedinherits fromBase<std::string>, the code compiles, - if I
return Base<T>::value, the code compiles.
Why doesn't the code compile as it is? In what way is 'value' not declared in the scope of Derived<T>::getValue()?