Re: vtable with virtual base class?
On 2008-12-12 13:38:53 -0500, Dave Johansen <davejohansen@gmail.com> said:
I would also like to point out the the Visual Studio documentation
claims "Virtual inheritance provides significant size benefits when
compared with nonvirtual inheritance. However, it can introduce extra
processing overhead.", see http://msdn.microsoft.com/en-us/library/wcz57btd
.aspx
What they're saying is that if you use virtual bases instead of
non-virtual bases, the resulting objects will often be smaller. That's
trivially true: if you only have one copy of a virtual base object
you'll often end up smaller than if you have half a dozen, despite the
added overhead of finding that base object. The "processing overhead"
is typically one or two extra dereferences to get at data in the
virtual base object through a pointer to a derived type.
But all of that is irrelevant if virtual bases have the wrong semantics
for what you're doing. The decision whether a base should be virtual
depends on its role in the class hierarchy. That's a design decision,
not an optimization.
I would still love to see a more detailed analysis to see what the
exact costs (memory and performance) are for using virtual
inheritance.
So do it. <g>
--
Pete
Roundhouse Consulting, Ltd. (www.versatilecoding.com) Author of "The
Standard C++ Library Extensions: a Tutorial and Reference
(www.petebecker.com/tr1book)