|
Turn The Screws! Open your eyes, look in front, look at the back, look at any angle and you will see something that is an engineer's creation. Engineers have been making things possible that others could only imagine. It perfectly makes sense to have a common place for engineers from around the world where they can share ideas, innovate, & help each other. Engineers are eternal, with the younger at 62 & the youngest at 17, the CEan gang consists of working professionals, students, entrepreneurs, CEOs, professors, geeks & nerds. Need we say more? Click Here To Join The Gang! |
![]() |
| Sponsored links | |
|
|
|
|
Good Administrator
![]() ![]() |
Well, most probably because the designers of Java wanted it to keep it a simple, object oriented language.
Java does support multiple inheritance through 'interfaces': Check: Java Multiple Inheritance and Designing with interfaces - Java World
__________________
-The Big K- Founder & Administrator ¤ The Big K’s Superblog™ ¤ About CE ¤ Small Talk ¤ CE Quick Start Guide for New Members ¤ Contact |
|
|
|
|
CE - Apprentice
![]() ![]()
I'm a Crazy Computer Science Engineer
Join Date: 13th January 2007
Posts: 24
|
Starting with what's the problem with multiple inheritance.
Let's start with a funny scenario. Consider a family, comprising of a child and his/her mom and dad A common behavior of mom and dad is that both are short tempered, with a difference that child's dad starts breaking things when angry, and mom only yells. Now, the child's also short tempered, but its impossible to know whether the short tempered behavior is his/her's mom's or dad's (assuming that child won't get both the behaviors So I guess, the problem with multiple inheritance is pretty clear Second question: Why java doesn't support it? I would rephrase the question, Why java doesn't allow it? In Java, the above scenario is resolved as ... in java, if the child is short tempered then its behavior must be known before its born ! Now, as stated in above replies that multiple inheritance is achieved via interfaces. Interfaces are not objects, and inheritance only exists between objects, so i guess its no more multiple inheritance I think this should answer your question.. By the way, i hate explaining OOP concepts with code, so if u were expecting it, m sorry, I won't n'joy
__________________
crAzy xerO |
|
|
|
| Sponsored links | |
|
|
|
|
CE - Apprentice
![]() ![]()
I'm a Crazy Computer Science & IT Engineer
Join Date: 30th June 2008
Posts: 12
|
Do you guys think that multiple inheritence is an ambiguous feature that an OO language should not allow?
C++ allows multiple inheritence. Check out this paper by Bjarne Stroustrup (inventor of C++) where he mentions its misconception. http://www-plan.cs.colorado.edu/diwan/class-papers/mi.pdf Also for the scenarios mentioned by shalini_goel14 and xero, we just need a scope resolution operator :: to decide which parent class's method should a child class's object invoke Also can you guys give me examples of some systems developed using C++, having problems or crashed, because of its multiple inheritence feature ? Last edited by prakash.athani : 7th July 2008 at 05:20 PM. |
|
|
|
|
CE - Apprentice
![]() ![]()
I'm a Crazy Computer Science Engineer
Join Date: 13th January 2007
Posts: 24
|
I'll start with clearing a mis conception that inheritance is a feature. Inheritance is a characteristic of OO paradigm, so multiple inheritance is not a feature, and it is ambiguous, but not bad :P
and yes C++ has its own way to implement it using virtual functions if i'm not wrong, so wherever multiple inheritance comes into picture, it would have been / will be implemented using the standard ways of C++ (either using virtual functions or any new mechanism ) And i don't think that applications/systems will ever crash if multiple inheritance is implemented, atleast i know about those written in C++. And even if it does crash, then its CURSED !! n'joy
__________________
crAzy xerO |
|
|
|
|
CE - Newbie
![]()
I'm a Crazy software Engineer
Join Date: 4th July 2008
Posts: 2
|
I like this little bit written by Bertrand Meyer:
Quote:
I must point out one more thing. We do inherit features from our parents but we are not our parents. That is, child is not its mother, neither is its father. Child has a mother and has a father so that can only be a client relationship not an inheritance. But CHILD can inherit from classes HUMAN_THAT_YELLS and HUMAN_THAT_BREAKS_THINGS that inherit from class HUMAN. If HUMAN has method engage_short_temper() and it is redefined in both classes HTY and HTB problem can be solved in two ways. First is that in CHILD we make one method from one parent deferred and take the method only from other parent. Second is that we rename methods and select one to use with dynamic binding when engage_short_temper() is called on HUMAN that is really a CHILD. |
|
|
|
|
| Sponsored links | |
|
|
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
| Contact Us - Home - Impressum | Impressum - Archive |