I have a template base class.Lets say.
template<class KeyF>
class Base
{
private:
int member1;
char member2;
....
};
I derived another class from above class.
template<class KeyF>
class Derived : public Base<KeyF>
{
public:
void func1() {
<accessing member1/member2>
}
....
};
Above code doesn't compile in gcc. saying that member1 is not a member of Derived. But it is already derived from a Base Class, then why can't it access its member?
Did you try protected? Been a bit since I was deep into C++...
Members in
Base
areprivate
. You cannot accessprivate members
of class, outside of this class (exceptfriend
). Make themprotected
, or makeprotected getters
.You need to prefix base member names with
this->
orBase<KeyF>::
, or add ausing
declaration to the class to unhide them. Their names are dependent names, and they are hidden.