Re: vtable with virtual base class?
On Dec 11, 6:12 pm, Dave Johansen <davejohan...@gmail.com> wrote:
Thanks for the response and it answered exactly what I was
looking for. I agree that the penalty is small and "worth
paying" to avoid the duplicated code, when it's REALLY
necessary and there's not a better design to handle the
problem.
I'm not sure what you mean by "really" necessary? Anytime
inheritance is being used to extend an interface, you should
probably use virtual inheritance. The cost is generally
negligeable, and virtual inheritance will be more robust with
regards to different client use.
In this regard, I'd suggest reading Barton and Nackman. They
discuss the various design trade-offs in detail.
Also, just for anyone else who may stumble along this thread.
I found this article
(http://www-plan.cs.colorado.edu/diwan/class-papers/mi.pdf)
and Section 7 actually discusses the logic behind the use of
virtual base classes to resolve the "diamond problem"
I couldn't find any mention of a "diamond problem" in it.
(I've found mention of a "diamond problem" is often a symptom
that the author really doesn't understand the issues that well.
The fact that you have a diamond in your inheritance graph is
not a problem; it is, in fact, perfectly normal.)
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S=E9mard, 78210 St.-Cyr-l'=C9cole, France, +33 (0)1 30 23 00 34