I am trying to override functions in my program in the method below but when compiling it shows variable1 as undefined in the Derived clear function.
I have been able to get this to work when changing the derived class to a non-template, but then I am missing the DATATYPE and VALUE variables when initiating the template for Base.
template <class DATATYPE=short, short VALUE = 100>
class Base {
public:
Base();
virtual void clear()=0;
protected:
int variable1;
}
template <class DATATYPE=short, short VALUE = 100>
class Derived : public Base<DATATYPE, VALUE> {
public:
Derived();
void clear() {
int testVar = variable1;
}
}