Originally Posted by
dwks
I wasn't using C-style casts, I was using dynamic_cast.
That was my first thought, but having data or having no data makes no difference. My understanding of this is pretty shaky, but here's what I think is happening. I think with multiple inheritance that instances of the class need two vtables, so that if an object is treated as one parent type, the appropriate methods can be looked up and called, and likewise for the other parent type.
So it would seem to me that there's no way to use multiple inheritance yet have the address of the object, no matter what base class it is casted to, be the same. Anyway, I'm not too concerned about this; I can always use the intrusive idea outlined above by brewbuck and bithub.
Or I could simply inherit every single class from a given (virtual) base class, then make ReferenceCounter always cast to this class when determining the address. I think that if this base class were virtual, it would always be located in the first vtable (at least that's what my experiments indicate), which would solve the problem.