3 ms·
Until now, there have been several different overlapping FAQs, including notably: Bjarne Stroustrup’s FAQ pages Marshall Cline’s popular C++
by brudgers 13y ago
Until now, there have been several different overlapping FAQs, including notably:
Bjarne Stroustrup’s FAQ pages
Marshall Cline’s popular C++ FAQs Online
at least three different StackOverflow C++ FAQs in some form....
and many others
What could be more apropos than multiple inheritance?
- pjmlp 13y agoGiven that all modern languages do support some form of MI, maybe it is time to stop bashing C++ about it.
- andrewflnr 13y agoMaybe, but how many other modern languages have the same diamond inheritance problem? Most modern languages put more limits on MI.
- pjmlp 13y agoAll of them have the same problem. It just shows up in different ways. In C++ case you have two main issues: - the decision to have or not virtual base classes, due to C++ design of only paying for what you use, the common solution to duplicate data members in OO languages is explicit in C++ - even if one restricts him/herself to use pure abstract classes without data members, as a way to implement interfaces, there is the problem of function members collisions. Some OO languages with inheritance of state usually get away with the data member duplication, either by doing what C++ compilers do with virtual base classes. The ones that adopt only some form interfaces/traits, have to deal with name clashes the same way as C++. All the existing solutions are kind of good enough, but not perfect: - Using of some form of linearisation algorithm every developer needs to be aware of, to understand which methods wins; - Members need to be renamed, thus changing the real interface meaning - Implementations are provided for each collided method, requiring either casts to specific interfaces or explicit calls for the right method - Provide just one implementation, with the caveat the semantics might not match all the interfaces that share the same method signature - Not allowing collisions, forcing the creation of an adapter interface So it is not well in the MI solutions outside C++. Each approach has plus and minus.
- deleted 13y ago[deleted]
- deleted 13y ago[deleted]