Say I have two templated classes, one pure virtual parent and another that inherits from the parent. Both are templated to take a generic type and a functor. For example:
template<typename T, typename funct>
class pure_virtual{
//pure virtual members
}
template<typename T, typename funct>
class child : public pure_virtual{
//members
}
In my main, I want to create a pure_virtual pointer to my child class without the use of dynamic memory. For example:
int main(){
pure_virtual<int*,my_functor>* p;
child<int*,my_functor> c(my_functor);
p = &c;
return 0;
}
This implementation gives me a compile error stating that it cannot convert type child into type pure_virtual. Any idea as to what I'm doing wrong here? I know if I use dynamic allocation, this will work; however, I would really like to avoid it if possible.
Thanks