Overload method in template child class

Viewed 52

I have the following Scenario:

I've got a child class looking like this:

template <typename T>
class Child : public AbstractBase {

   virtual void Test(T *obj, void (T::*ptr)(int)) {
      (*obj.*ptr)(5);
   }

}

And the Base Class looks like this:

class AbstractBase {
   virtual void Test(T*, ??) = 0;
}

Is there any possible way to fill the ??, so I can override the method in my Child class?

What I'd ultimately like to do is to store lots of Child objects in one list (list< AbstractBase* >), but with different types (different Ts).

Using the class would look like this:

#include "Child.h"
class A {
    A() {
       AbstractBase *ab = new Child<A>();
       ab->Test(this, &A::foo);
    }

    void foo(int a) {}
}
0 Answers
Related