Sorry if this has been asked before. I haven’t found a distinct answer.
I have two classes, motorbike and car. The only difference is number of wheels and number of passengers allowed.
In this case, would I use motorbike as the base class (and have car be the subclass), or create a new ‘vehicle’ base class?
>Solution :
Generally, inheritance is used to model an "isA" relationship.
A car has similar parts to two motorbikes, but a car is not a motorbike.
Both cars and motorbikes, however, are vehicles.
So if it were me, I would use a vehicle class as a base class, and derive both car and motorbike from it.