In C++, why is the address changed when the pointer is converted?
Following is the code: #include <iostream> using namespace std; class B1 { public: virtual void f1() { cout << "B1\n"; } }; class B2 { public: virtual void f1() { cout << "B2\n"; } }; class D : public B1, public B2 { public: void f1() { cout << "OK\n" ; } }; int main () { D dd; B1 *b1d = ⅆ B2 *b2d = ⅆ D *ddd = ⅆ cout << b1d << endl; cout << b2d << endl; cout << ddd << endl; b1d -> f1(); b2d -> f1(); ddd -> f1(); } The output is : 0x79ffdf842ee0 0x79ffdf842ee8 0x79ffdf842ee0 OK OK OK This looks confusing to me, because I expected b1d and b2d would be the same as both of them point to