Observe the following program.
class Base{
protected:
int datum;
};
class D: public Base{
public:
int Get_Datum(){
return datum;
}
};
int main(){}
The base class holds a member variable. We've explicitly stated that the member variable is an integer. The derived class can inherit from the base class and access that member variable. This compiles and works as expected.
Now let's try the same thing but have the data member deduced at compile time.
template <typename Datum>
class Base{
protected:
Datum datum;
};
template <typename Datum>
class D: public Base<Datum>{
public:
int Get_Datum(){
return datum;
}
};
int main(){}
15:10: error: ‘datum’ was not declared in this scope
How do I edit this in order to get it to work the same way as the first example? Do I have to do something with the constructors?