Re: factoring book question and cast question.
Francis Glassborow wrote:
In article <1169822128.883348.275870@m58g2000cwm.googlegroups.com>,
James Kanze <james.kanze@gmail.com> writes
That statement surprizes me. I've worked on applications with
as many as 8 virtual base classes in a hierarchy, and it didn't
cause any problems. As a general rule, if you're inheritance is
for the typical OO reasons, you should use virtual inheritance
unless there is some very strong reason not to. (It's another
case where C++ got the default wrong: inheritance should be
virtual by default, and non-virtual only when you explicitly
say so.)
Are we writing about the same thing?
I think so.
class A { ... };
class B { ... };
class C { ... };
class D: virtual public A, virtual public B, virtual public C { ... };
class E: public D {... };
class F: public E, virtual public B { ... };
etc. ?
Yep.
At the very least your virtual base classes better have default ctors
etc.
Obviously.
Note that I am not talking about Abstract Base Classes that are beasts
of a very different kind.
There's a relationship. You never derive from an abstract base
class (an "interface") except virtually. (I'm exagerating, of
course. Within an application, if you've done the design, you
know who derives from whom, and you can use virtual inheritance
in a more limited fashion. But when in doubt, virtual
derivation is the default.)
--
James Kanze (Gabi Software) email: james.kanze@gmail.com
Conseils en informatique orient?e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S?mard, 78210 St.-Cyr-l'?cole, France, +33 (0)1 30 23 00 34
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]