#include <iostream>
struct B1 {};
struct B2 {};
struct D : public B1, B2 {};
int main(int argc, char **argv) {
using namespace std;
cout << "B1:" << sizeof(B1) << endl;
cout << "B2:" << sizeof(B2) << endl;
cout << "D:" << sizeof(D) << endl;
cout << "D::B1:" << sizeof(D::B1) << endl;
cout << "D::B2:" << sizeof(D::B2) << endl;
D d;
cout << &static_cast<B2&>(d) << " , " << &d << endl;
cout << &(B2&)d << " , " << &d << endl;
D da[2];
cout << &static_cast<B2&>(da[0]) << " , " << &da[1] << endl;
cout << &(B2&)da[0] << " , " << &da[1] << endl;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKc3RydWN0IEIxIHt9OwpzdHJ1Y3QgQjIge307CnN0cnVjdCBEIDogcHVibGljIEIxLCBCMiB7fTsKCmludCBtYWluKGludCBhcmdjLCBjaGFyICoqYXJndikgewogICAgdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCgljb3V0IDw8ICJCMToiIDw8IHNpemVvZihCMSkgPDwgZW5kbDsKCWNvdXQgPDwgIkIyOiIgPDwgc2l6ZW9mKEIyKSA8PCBlbmRsOwoJY291dCA8PCAiRDoiIDw8IHNpemVvZihEKSA8PCBlbmRsOwoJY291dCA8PCAiRDo6QjE6IiA8PCBzaXplb2YoRDo6QjEpIDw8IGVuZGw7Cgljb3V0IDw8ICJEOjpCMjoiIDw8IHNpemVvZihEOjpCMikgPDwgZW5kbDsKCglEIGQ7Cgljb3V0IDw8ICZzdGF0aWNfY2FzdDxCMiY+KGQpIDw8ICIgLCAiIDw8ICZkIDw8IGVuZGw7Cgljb3V0IDw8ICYoQjImKWQgPDwgIiAsICIgPDwgJmQgPDwgZW5kbDsKCUQgZGFbMl07Cgljb3V0IDw8ICZzdGF0aWNfY2FzdDxCMiY+KGRhWzBdKSA8PCAiICwgIiA8PCAmZGFbMV0gPDwgZW5kbDsKCWNvdXQgPDwgJihCMiYpZGFbMF0gPDwgIiAsICIgPDwgJmRhWzFdIDw8IGVuZGw7CglyZXR1cm4gMDsKfQoK