Suppose you’re working with a class your colleague wrote, and you want to extend that class’ functionality. How would you do it, without modifying the original code? Well, one approach is inheritance: you make a derived class, add the functionality you need, maybe even override something, and you’re good to go.
Right, except this doesn’t always work, and there are many reasons why. The most common reason is that you cannot inherit the class – either because your target class needs to inherit something else (and multiple inheritance is impossible) or because the class ...