#include <iostream>
using namespace std;
struct B {
int f() { cout << "B::F\n"; }
};
struct A { int x; A() : x(42) {} };
struct D : A, B {
int g() { cout << "D::G" << x << "\n"; }
};
int main()
{
D d;
B b;
B* pb = &b;
int (B::*pf)() = &B::f;
(pb->*pf)();
pb = &d;
pf = (int(B::*)())&D::g;
(pb->*pf)();
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCnN0cnVjdCBCIHsKICBpbnQgZigpIHsgY291dCA8PCAiQjo6RlxuIjsgfQp9OwoKc3RydWN0IEEgeyBpbnQgeDsgQSgpIDogeCg0Mikge30gfTsKCnN0cnVjdCBEIDogQSwgQiB7CiAgaW50IGcoKSB7IGNvdXQgPDwgIkQ6OkciIDw8IHggPDwgIlxuIjsgfQp9OwoKaW50IG1haW4oKQp7CiAgRCBkOwogIEIgYjsKICBCKiBwYiA9ICZiOwogIGludCAoQjo6KnBmKSgpID0gJkI6OmY7CiAgKHBiLT4qcGYpKCk7CgogIHBiID0gJmQ7CiAgcGYgPSAoaW50KEI6OiopKCkpJkQ6Omc7CiAgKHBiLT4qcGYpKCk7CiAgcmV0dXJuIDA7Cgp9Cg==