Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Dangers of Multiple Inheritance

Reply
Thread Tools

Dangers of Multiple Inheritance

 
 
Corno
Guest
Posts: n/a
 
      09-23-2003
Hi all,

I know there are quite a few arguments in favor or against MI. I know there
are a lot of usenet discussions about wether MI is actually needed or not.
These discussions mention the 'dangers' of MI.
The problem is; I know that there are dangers concerned with MI and I know
how I can avoid them, I just don't have a clear idea of what the dangers
actually are and if they are applicable to to the situations I encounter.
The only danger I (think I) really understand is the dreaded diamond.
But there also seems to be an issue with copying and assignment which I
don't see.
And is there more danger that I should be aware of? and will these problems
surface during compiling or runtime?

Does anybody know a good article specifically about this or else would
somebody care to explain it to me in this newsgroup?

TIA,

Corno


 
Reply With Quote
 
 
 
 
Michel de Becdelièvre
Guest
Posts: n/a
 
      09-23-2003
"Corno" <corno@%spam%.dds.nl> a écrit dans le message de
news:bkpcqk$1mj$(E-Mail Removed)...
> And is there more danger that I should be aware of? and will these

problems
> surface during compiling or runtime?


It is at least partially a case of saying it is dangerous to avoid having to
implement it in many GC based languages.
It apparently makes building an efficient GC more difficult to design (not
impossible, see Eiffel).
So Java & C# designer replaced it with interfaces (multiple inheritance
without data) as a workaround.



 
Reply With Quote
 
 
 
 
David B. Held
Guest
Posts: n/a
 
      09-23-2003
"Corno" <corno@%spam%.dds.nl> wrote in message
news:bkpcqk$1mj$(E-Mail Removed)...
>
> I know there are quite a few arguments in favor or against MI. I
> know there are a lot of usenet discussions about wether MI is
> actually needed or not.


MI is "not needed" in the way that classes "aren't needed". That is,
you can write equivalent programs without it, but the feature makes
some designs a lot simpler.

> [...]
> The only danger I (think I) really understand is the dreaded
> diamond.


LOL@"dreaded" The diamond inheritance diagram strikes fear in
the hearts of coders!

> But there also seems to be an issue with copying and assignment
> which I don't see.


I don't see it either. You have to make sure that all your base
classes agree on how to copy and assign, but I'm not aware of any
nasty gotchas.

> And is there more danger that I should be aware of? and will these
> problems surface during compiling or runtime?


One issue to keep in mind is size. Many, if not most compilers will
make your derived class much bigger than it would be if you did
not use MI (but rather used a chained approach). There is a solution
for this, but it's a little tricky, and has its own set of issues.

> Does anybody know a good article specifically about this or else
> would somebody care to explain it to me in this newsgroup?


An interesting discussion to check out would be on the Boost
developer list. You can find the archives on Google. The thread
is about Loki::SmartPtr, which uses MI in a big and obvious way.
Quite a few issues relating to MI came up in that discussion. Look
for 'SmartPtr' and 'MI'.

Dave


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dangers of Media Conglomeration (This Film is Not Yet Rated) Jordan DVD Video 3 02-16-2007 03:07 PM
Dangers of occular diabetes fom Vista Andromedan Windows 64bit 13 10-16-2006 04:37 PM
OT - More on the dangers of internet banking DAVO Computer Information 103 09-18-2006 02:08 PM
Dangers in copying pics from camera to computer macca Digital Photography 195 02-07-2006 11:40 PM
WinXP SP2 Dangers? VWWall Computer Information 9 07-30-2004 05:10 PM



Advertisments