On Oct 29, 4:46?am, "Daniel T." <danie...@earthlink.net> wrote:
?Joshua Maurice <joshuamaur...@gmail.com> wrote:
With this multiple inheritance design, I would guess that you
probably want to virtually inherit from Fooer as well (not done in
the above code).
Virtual inheritance would only be necessary if Fooer had
member-variables. Inheriting interfaces (classes with only pure
virtual functions and no member-variables,) does not require virtual
inheritance.
I'm not so sure about this. Let me think about it.
At the very least, if you inherit from such an "interface" class
twice, then you will have two distinct base class sub-objects, and
they will have distinct addresses. (IIRC, the intent of the standard
is that two objects (complete or sub-objects) of the same type should
be distinct objects iff they have distinct addresses. However, I
recall that the wording might have been changed to remove this
requirement. Not sure what the situation is.) I would think that that
is counter-intuitive. I think that a programmer might simply assume
that if he has two distinct Fooer (sub)objects (distinct according to
distinct addresses), then he has two distinct complete objects.
However, such inference would be incorrect without virtual inheritance.
The empty base class optimization means that the above is not the case.
address.