#include <iostream>

    struct fooA {
    	int foo1(int x, int y) { return x + y; }
    	int foo2(int x, double y, void*) { return x + y; }
	};
    struct fooB {
    	void foo1(int x, int y) { std::cout << "fooB(" << x << ", " << y << ")\n"; }
    	void foo2(int x, double y, void* z) { std::cout << "fooB(" << x << ", " << y << ", " << z << ")\n"; }
    };
    struct fooC {
    	void foo1(int x, int y) { std::cout << "fooC(" << x << ", " << y << ")\n"; }
    	void foo2(int x, double y, void* z) { std::cout << "fooC(" << x << ", " << y << ", " << z << ")\n"; }
    };
    
    class foo {
    public:
        void foo1(int x, int y)
        {
            dispatch(&fooA::foo1, &fooB::foo1, &fooC::foo1, x, y);
        }
        void foo2(int x, double y, void *z)
        {
            dispatch(&fooA::foo2, &fooB::foo2, &fooC::foo2, x, y, z);
        }

    private:
        template <typename... Args>
        void dispatch(int (fooA::* f)(Args...),
                      void (fooB::* g)(Args...),
                      void (fooC::*h)(Args...),
                      Args... args)
        {
           switch((m_Member.*f)(args...)) {
           case 1: (m_Member1.*g)(args...); return;
           case 2: (m_Member2.*h)(args...); return;
           }
        }

        fooA m_Member;
        fooB m_Member1;
        fooC m_Member2;
    };

int main() {
	foo dispatcher;
	dispatcher.foo1(1, 0);
	dispatcher.foo2(1, 1, 0);
	return 0;
}