Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Lestat3D

Multiple inheritance problems

This topic is 6045 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

What happens if I make a class that inherits from two classes in the same way and those two classes have variables and/or functions with the same name and the same data tyipe and/or the same parameter list?

Share this post


Link to post
Share on other sites
Advertisement
Then you''d get ambiguity. That means the derived class will need to be explicitly cast every time an ambiguous function is called.

Basically its a good idea to avoid this



Reach out and torch someone.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Multiple inheritance is evil!

Interestingly, Ruby, a full-featured OO scripting language, does not permit multiple inheritance for this reason. Instead, it allows for the creation of modules - collections of properties and methods - that can be mixin''ed with any class.

Share this post


Link to post
Share on other sites
Multiple inheritance isn''t evil, it''s just not recommended for most applications.

when you have
class Base1 and class Base2

the class Derived will have all the members and like Null and Void said you would just specify which class your referring too by calling instance_of_derived.Base1::Function();

Also to avoid alot of ambiutity (spelling?) you would make the functions that are common to both bases a virtual function. So then it doesn''t matter which one you call.

Pactuul

Share this post


Link to post
Share on other sites
Some of the properties of multiple inheritance are useful, but I think the Ruby approach eliminates a lot of its ambiguities and problems (the Anonymous Poster was me, btw). In any case, it''s not going away, so...



I wanna work for Microsoft!

Share this post


Link to post
Share on other sites
How many OO languages have MI anyway? I can think of only two, namely C++ and Eiffel(or so I have heard). The original OO language, Simula, did not have MI, and neither did Smalltalk. Most newer languages seem to either use the interface paradigm(Java, C#), or are dynamically typed(Python).

"I contend that we are both atheists. I just believe in one fewer god than you do. When you understand why you dismiss all the other possible gods, you will understand why I dismiss yours." - - Stephen Roberts

Share this post


Link to post
Share on other sites
C++ ownz, why? Because we have a lot of freedom in the language
and we can choose if we want multiple inheritance or not.

And it isn''t evil at all, that''s just a plain silly statement.
Bad design is evil, bad lead programmers and project leaders are evil.

If the code calls for MI why not use it? ...one should be aware of the pitfalls, but that goes for everything in programming doesn''t it?

The funny thing is that the standard C++ library uses MI itself so we are all using MI to some extent in C++.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!