I can have a typedef function pointer in a class like this:
template<typename T>
class MyClass
{
public:
typedef T (*fptr)(T);
void doSomething(fptr my_fptr) { /*...*/ }
};
and this works fine. but if I inherit from such a class, as below:
template<typename T>
class MyClass
{
public:
typedef T (*fptr)(T);
virtual void doSomething(fptr my_fptr) = 0;
};
template<typename T>
class MyOtherClass: public MyClass<T>
{
public:
void doSomething(fptr my_fptr) { /*...*/ }
};
the compiler complains that fptr is undefined. is there a way of inheriting function pointer typedefs like this? thanks,
james
You should be able to inherit public typedefs like that.
Did you try something like this to make sure the compiler know it’s a parent type: