Jump to content
  • Advertisement
Sign in to follow this  
luasitdown

Mutiple inheritance

This topic is 4885 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Mutiple inheritance is very good at Abstract interface. I hear of mutiple inheritanc having many shortcoming. like Diamond of Dead ,complex structure etc... but why do not Abstract interface adopting mutiple inheritance have these flaw? Abstract interface have magic?

Share this post


Link to post
Share on other sites
Advertisement
Multiple interface realization is safe because you don't have to wonder what implementation gets called. That's why many 'modern' languages dropped multiple inheritance and adopted multiple interface realization.

Cheers

[Edited by - ernow on July 31, 2005 3:34:32 AM]

Share this post


Link to post
Share on other sites
"multiple inheritance" as understood in C++ means multiple inheritance of implementation, which supersets multiple inheritance of interface. If you only inherit an interface, then you don't add any data from the inherited base, which generally avoids the problems. ("Diamond inheritance" becomes a problem because both parent classes have the grandparent as a base, which means the child ends up with two separate copies of the grandparent base in its data layout.) In languages like Java, you can only inherit implementation from one class, but you can create interfaces and implement as many of those as you like, which adds an increased measure of safety.

Those who advocate multiple inheritance of implementation usually like the ability to create "mix-in" classes, which is really just a way to save typing versus doing ordinary object composition (where you would have to type out a bunch of code to do "delegation" to the aggregated objects). Personally I feel this is something that would be better handled by language support for delegating things automatically (or at least, with minimal instruction from the coder about "who handles what interface"). Unfortunately I don't know of any languages that do this.

Share this post


Link to post
Share on other sites
Quote:
Original post by Zahlman
Those who advocate multiple inheritance of implementation usually like the ability to create "mix-in" classes, which is really just a way to save typing versus doing ordinary object composition (where you would have to type out a bunch of code to do "delegation" to the aggregated objects).


could you please explain these more detail?
what is delegation and aggregated objects.
thanks

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!