#include <iostream>

using namespace std;

class c1 {
public:
    void f1(){std::cout<<"In f1\n";}
};

class c2 {
public:
    void f2(){std::cout<<"In f2\n";}
};

template<typename> struct which_member;

template<> struct which_member<c1> {
    static constexpr void (c1::* func)() = &c1::f1;	
};

template<> struct which_member<c2> {
    static constexpr void (c2::* func)() = &c2::f2;	
};

template <typename T>
class C: public c1, c2 {
public:

    void f() {
        (static_cast<T*>(this)->*which_member<T>::func)();
    }
};

int main()
{
    C<c2> c;
    c.f();
    return 0;
}