I try to make a class template where a parameterized class Child inherits from a parameterized class Base. The derived class cannot access the members in the base class though.
template <typename T>
class Base
{
protected:
T _value;
};
template <typename T>
class Child: Base<T>
{
public:
T accessValue()
{
return _value;
}
};
This gives the following error message:
main.cpp: In member function 'T Child::accessValue()': main.cpp:21: error: '_value' was not declared in this scope
It works if I change the declaration to:
template <typename T>
class Child: Base<int>
but that obviously defies the purpose of the whole template thing.
I Think this must be something really basic but I could not find a solution neither on this site nor anywhere else. Can someone please help me? Thanks in advance!