I am trying to figure out how I can access the members of a base template class inside the derived class.
I have a base template class and a derived class as shown below.
template<int dim>
class base_class
{
public:
base_class() = default;
int member_ = 0;
};
template<int dim>
class derived_class : public base_class<dim>
{
public :
derived_class() : base_class<dim>::member_(1) {}
};
int main(int argc, char* argv[])
{
derived_class<2> dc;
return 0;
}
I read (https://stackoverflow.com/questions/4643074/why-do-i-have-to-access-template-base-class-members-through-the-this-pointer) that I must prepend the member of the derived class as
base_class<dim>::member_.
However the compiler gives the following error:
error: no type named ‘member_’ in ‘class base_class<2>’ derived_class() : base_class<dim>::member_(1) {}
I do not understand why. Can anybody help me?