By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,918 Members | 1,852 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,918 IT Pros & Developers. It's quick & easy.

Any use of multiple inheritance?

P: n/a
It seems no pattern defined by GoF takes advantage of multiple
inheritance. I am wondering if there is a situation where multiple
inheritance is a necessary solution.

When coding in C++, should multiple inheritance still be avoided?

If yes, why multiple inheritance is introducted into C++?
Jul 22 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Morgan Cheng wrote:
It seems no pattern defined by GoF takes advantage of multiple
inheritance. I am wondering if there is a situation where multiple
inheritance is a necessary solution.
There is no situation where mutiple inheritance is *necessary*.
Of course, there is also no situation where inhertiance is
*necessary*. After all, everything we can do with C++ can also
be done with a Turing machine and there is no such thing as
inheritance there.
When coding in C++, should multiple inheritance still be avoided?


Inheritance should be avoided (note the deliberate absence of
"multiple"). You should use inheritance only when it makes your
design simpler. If multiple inheritance makes your design
simpler, you should use multiple inheritance. ... and, yes,
there are indeed some situations where inheritance is the
right way to go. The same applies to multiple inheritance. Just
because the GoF does not use them does not mean that it's
useless.
--
<mailto:di***********@yahoo.com> <http://www.dietmar-kuehl.de/>
<http://www.contendix.com> - Software Development & Consulting

Jul 22 '05 #2

P: n/a
Actually, class adapter from GoF (see page 141) uses multiple
inheritance.

Also, I advise you to read this interview with Bjarne Stroustrup:
http://www.artima.com/intv/modern.html

Jul 22 '05 #3

P: n/a

"Morgan Cheng" <mo************@gmail.com> wrote in message
news:cp**********@avnika.corp.mot.com...
It seems no pattern defined by GoF takes advantage of multiple
inheritance. I am wondering if there is a situation where multiple
inheritance is a necessary solution.


Multiple inheritance can be useful for "mix-in" classes. Or as Stroustrup said
in that interview (I believe he is talking about the same thing) - "you just
want to combine a couple of classes that you happen to have."
Jul 22 '05 #4

P: n/a
nt*********@hotmail.com wrote:
Actually, class adapter from GoF (see page 141) uses multiple
inheritance.
Yes. But it is recommended to use object adapter instead of class adapter.
Also, I advise you to read this interview with Bjarne Stroustrup:
http://www.artima.com/intv/modern.html

Jul 22 '05 #5

P: n/a
Take a look at Modern C++ design, it is used elegantly with templates for
Policies.
"Morgan Cheng" <mo************@gmail.com> wrote in message
news:41**************@gmail.com...
nt*********@hotmail.com wrote:
Actually, class adapter from GoF (see page 141) uses multiple
inheritance.

Yes. But it is recommended to use object adapter instead of class adapter.
Also, I advise you to read this interview with Bjarne Stroustrup:
http://www.artima.com/intv/modern.html

Jul 22 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.