Both systems provide multiple inheritance, but go about it very differently.
The most important difference is that \Cplusplus\ provides only \emph{static
delegation}: if you have a class @|B| which defines some (virtual) member
-function @|f|, and a derived class of @|D| which wants to \emph{extend} the
+function @|f|, and a derived class @|D| which wants to \emph{extend} the
behaviour of @|f| on instances of @|D|, then you must explicitly call @|B::f|
at the appropriate point:
\begin{prog}
and `after' actions are both in the middle.\footnote{%
Of course, one could have arranged to call @|Y::f| before @|X::f| -- but
the important point is that one would have needed to \emph{know} that this
- was necessary.} %
+ was necessary. And you still end up with two copies of `B'.} %
The problem is that correctly composing behaviour from a collection of
superclasses requires knowledge of all of the superclasses involved and how
-they're supposed to work together.
+they're supposed to work together. Messing with virtual base classes has
+eliminated the problem of duplicating @|B|'s state, but has done nothing to
+help avoid duplicating @|B|'s \emph{behaviour} -- which is a shame, because
+duplicating one without the other is going to end badly.
The obvious workaround is to separate the functionality -- here, printing the
messages -- from the plumbing, which arranges to do everything in the right
void _f() \{ std::cout <{}< "B@\\n"; \} \-\\
public: \\ \ind
virtual void f() \{ _f(); \} \\
- virtual ~B() \{ \} \-\\
+ virtual @~B() \{ \} \-\\
\}; \\+
%
class X: virtual public B \{ \\