Function pointer in a subclass?


I have a function pointer variable in my AItem class, which looks like this: ‘void (AItem::*MyPointer)()’.
In the AItem it works just fine, I can assign it (MyPointer = &AItem::MyFunction) and call it (MyPointer()).
But I cannot assign it in subclasses like (MyPointer = &AItemSubclass::MySubclassFunction).

Is it possible to have a function pointer which works for subclasses as well?


Would it maybe work if I use a similar setup like the SetTimer function?
I had a look at the source code of this function, but I couldn’t figure out how to transfer this to my own class.
I need to have a function that takes any function (of a class tree) and stores it in a variable, so I can call it later on.

Any ideas on that?


Did you see this;

Check out the bit that says;

 //The actual functions which are implemented in subclasses
//or this class itself
virtual void PlayBehavior_Idle_LookLeftToRight();
virtual void PlayBehavior_Idle_LookFullCircle();
virtual void PlayBehavior_Idle_ScanUpDown();
//...more functions

Hey, Yes I have read that article. He is using function that he overrides in subclasses, which would work, but the idea was to declare new functions in the sublcasses that can be saved as a delegate.