472,354 Members | 1,895 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,354 software developers and data experts.

Any use of multiple inheritance?

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
5 2049
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
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

"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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Graham Banks | last post by:
Does using multiple inheritance introduce any more performance overhead than single inheritance?
20
by: km | last post by:
Hi all, In the following code why am i not able to access class A's object attribute - 'a' ? I wishto extent class D with all the attributes of its base classes. how do i do that ? thanks in...
22
by: Matthew Louden | last post by:
I want to know why C# doesnt support multiple inheritance? But why we can inherit multiple interfaces instead? I know this is the rule, but I dont understand why. Can anyone give me some concrete...
47
by: Mark | last post by:
why doesn't .NET support multiple inheritance? I think it's so silly! Cheers, Mark
60
by: Shawnk | last post by:
Some Sr. colleges and I have had an on going discussion relative to when and if C# will ever support 'true' multiple inheritance. Relevant to this, I wanted to query the C# community (the...
15
by: iKiLL | last post by:
hi all, I would like to be able to create an umbrella class for all my main global sections but I would still like to keep them all in separate file something like the below but I keep getting...
7
by: Adam Nielsen | last post by:
Hi everyone, I'm having some trouble getting the correct chain of constructors to be called when creating an object at the bottom of a hierarchy. Have a look at the code below - the inheritance...
47
by: Larry Smith | last post by:
I just read a blurb in MSDN under the C++ "ref" keyword which states that: "Under the CLR object model, only public single inheritance is supported". Does this mean that no .NET class can ever...
2
by: Paul McGuire | last post by:
On May 25, 8:37am, Michael Hines <michael.hi...@yale.eduwrote: Here's a more general version of your testing code, to detect *any* diamond multiple inheritance (using your sample classes). --...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made but the http to https rule only works for...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. header("Location:".$urlback); Is this the right layout the...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.