I\'m writing some code involving inheritance from a basic ref-counting pointer class; and some intricacies of C++ popped up. I\'ve reduced it as follows:
Suppose I h
C
embeds an A
and a B
.
class C: public A, public B {};
is very similar to the C code
struct C {
A self_a;
B self_b;
};
and (B*) &c;
is equivalent to static_cast< B* >( &c )
is similar to &c.self_b
if you were using straight C.
In general, you can't rely on pointers to different types being interchangeable or comparable.