In Item 27 of \"Effective C++\" (3rd Edition, Page 118), Scott Meyers said:
class Base { ... };
class Derived: public Base { ... };
Derived d;
Base *pb = &am
Just try it:
class B1
{
int i;
};
class B2
{
int i;
};
class D : public B1, public B2
{
int i;
};
int
main()
{
D aD;
std::cout << &aD << std::endl;
std::cout << static_cast( &aD ) << std::endl;
std::cout << static_cast( &aD ) << std::endl;
return 0;
}
There's no possible way for the B1 sub-object to have the same
address as the B2 sub-object.