The FAQ says, "If you are relying on order dependencies in a virtual
inheritance hierarchy, you'll need a lot more information than is in
this FAQ."
Can someone post that information here?
I was under the impression that when a base class has a virtual
destructor, that the destruction order is from most derived to base.
I've got a tricky smart pointer member that is going to depend on this
and wanted to verify that it is always guarenteed.
P.S.
On an aside, the FAQ is FAQ LITE, is there a FAQ Full Flavor?
The standard is very clear on the order that a class hierarchy is
constructed, (and by the reverse order rule, destructed). The basic rule
is that when a constructor for a class is entered, it first calls the
constructor from base classes, in a left to right order, then the
constructors for its member variables in deceleration order.
The one hiccup to this order is virtual base classes, as those may be
mentioned several places in the inheritance tree, but all these
represent a single sub-object that will only be constructed once. I
don't know if the standard gives a precise timing of when this object is
created, but I am fairly sure that it is guaranteed to have been created
by at least the point where it have been by the basic rule. I suspect
that virtual base classes will need to be created before any of the
"normal" base classes, but I don't know it that is promised by the
standard. Note that if you inherit from a base class that has a virtual
base class, even if you do not specify that you inherit from that
virtual base, your constructor is still going to need to construct that
virtual base, it doesn't get deferred to your base that declared the
relationship.
As has been pointed out, this (and what the FAQ is referring to) is
virtual inheritance, "class foo: virtual pubic bar, public baz {}" not
just a virtual destructor. A virtual destructor just make sure that the
right destructor gets called if you delete an object through a pointer
to a base class (without the virtual destructor, this operation causes
undefined behavior).