lundi 24 octobre 2022

C++: Composition vs. Multiple Inheritance and Implications for Maintenance [closed]

When considering inheritance for code reuse (i.e. not only for interfaces), multiple inheritance would be necessary for most non-trivial cases. As an alternative, composition is usually preferred. I know that this topic has been discussed extensively here, but I still feel like I did not grasp the aspect of maintenance:

Why is composition considered to be easier to maintain?

Can you give me a concrete example, when and how MI would lead to code that is hard to maintain? I found many answers that describe the problems of MI, but fail to connect how they actually affect code maintenance in a negative way.

Aucun commentaire:

Enregistrer un commentaire