Inheritance vs Composition
Ive been reading a book called Thinking in C++ by Bruce Eckel and came across an interesting point. He mentioned somewhere that for many newcomers, inheritance is often over-emphasized and it is more practical for most situations to use composition instead. (Composition is objects within another) I personally found this to be true as I have never actually found inheritance as the *only* or *best* means of accomplishing a task and many times have found the method composing to make much more conceptual sense. Take for example a class called carpark, and a class called car. It is obvious you would not inherit carpark to car but you would want to somehow encapsulate them. (so an answer I see to this is composition, i.e. an array of cars within a carpark perhaps) My question is when is inheritance *actually* needed? (And yes I know of the classic twodshape, triangle, redTriangle etc example.) And do you think it's true that the inheritance concept is over-emphasized by tutorials?