template <class T> struct Interface {
T * p ;
Interface(T * p) : p(p) { }
void f() { p->T::f() ; }
} ;

struct D: B1, B2 {
Interface<B1> base1() { return this; }
Interface<B2> base2() { return this; }
void f();
};

D d;
d.base1().f() // B1のf
d.base2().f() // B2のf
d.f() // Dのf