I am not able to solve the error in c++ template inheritance related code.
template <class row>
struct tableBase
{
typedef row pkeytype;
int k;
};
template <typename row>
struct table:tableBase<typename row::pkeytype>
{
row r;
};
struct astruct {
typedef int pkeytype;
char y;
};
table<astruct> atable;
tableBase<astruct> * u=&atable;
error: cannot convert table<astruct>* to tableBase<astruct>* in initialization
That’s because the parent of
table<astruct>istableBase<int>NOTtableBase<astruct>which are two totally unrelated types.Unfortunately since I can’t conjecture what you’re attempting to accomplish here I can’t offer any suggested solutions.