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. For example, you typically wouldn’t want to inherit from, say, std:: vector due to its lack of a virtual destructor, or from int (that’s just impossible). But the most critical reason why inheritance doesn’t ...