#include <cstdio>
#include <functional>


class B { 
public:
    typedef std::function<void (B*)> Function;    

    void f3() {
        puts("okay");
    }
    void f1() {   
        _func(this);
    }

    Function _func;
};

class D : public B 
{
public:
    D()
    {
        _func = (void (B::*)()) &D::f2; // Here is the awfull cast I hate to do
    }

    void f2() {
        f3();
    }

};

int main() {
    D d;
    d.f1();
}