Posted: Aug 12, 2010 10:52 pm
by VazScep
Calilasseia wrote:Oh, and one idea that has led to a lot of trouble in C++ is allowing child objects to inherit from multiple parents. This has been a source of numerous insidious and troublesome bugs in some large projects. The people responsible for Java specifically forbade multiple inheritance within the Java language because of it.

Within C++, it's possible to define two objects, have them both share a name for a method, then define a third object that inherits from these two, at which point, you have the less than happy scenario of deciding which of the identically named methods from which of the parents is going to be overridden in the child object. Worse still, because of the flexibility of method overloading, I've been told it's possible to have the child object refer to overridden versions of both of the parent methods via the same method label ... which again, drives a sodding tank battalion through the OOP paradigm.

Needless to say, I wouldn't trust a mission critical application to this language platform unless there were very strict rules in place as to what programmers could and couldn't do.
I don't think the ambiguity is really an issue, because the semantics of the look-up are well-defined. The diamond inheritance problem is another matter, where a derived class inherits two copies of an ancestor class by multiply inheriting parents. The correct behaviour here is achieved by explicitly using virtual inheritance, which C++'s programmers generally don't want for performance reasons, so you end up having to plan for multiple inheritance way in advance. This is the whole problem with nominal subtyping: you can plug new classes into an interface scheme, but you can't plug in new class diagrams.