example:
class A{
int x;
};
class B{};
class C : public A, public B {};
C c;
A* a = &c;
B* b = &c;
when I check the value of &c and b, they are different because b is after a in memory, but yet when I evaluate &c==b, they are the same, why is the case?
In the expression
&c == bboth operands have to be coerced to the same type. In this case&c(aC*) can be converted toB*asBis an accessible base class ofC. This is exactly the same conversion as happens inB* b = &cso the resulting values are the same and the comparison returns true.