I am new to C++. During my learning phase I encountered with below issue.
I am trying to derive a class stack
from a class template Queue
.
Compiler thr
Because the base class is a template, whose instantiation depends on a template parameter of the derived class, and you're trying to name a member of the base class, two-phase lookup mandates that you write this->b
, not b
.
(And that default constructor call is not needed.)
stack()
{
this->b = this->a;
}
void pop()
{
this->b--;
}
Welcome to C++… :P
[C++11: 14.6.2/3]:
In the definition of a class or class template, if a base class depends on a template-parameter, the base class scope is not examined during unqualified name lookup either at the point of definition of the class template or member or during an instantiation of the class template or member. [..]