3 ms·
> Nobody said that inheritance must be polymorphic Polymorphim normally means dispatch based on type of the first argument to a function, sometimes called a me
by JonChesterfield 4y ago
> Nobody said that inheritance must be polymorphic
Polymorphim normally means dispatch based on type of the first argument to a function, sometimes called a method. Occasionally dispatch based on type of all arguments to a function.
Inheritance is a means of deriving types from other types. That's usually done as a means of controlling dispatch via the above polymorphism. I don't know of a different motive for inheritance. You claimed inheritance doesn't need to be polymorphic, as quoted above, so I hoped you had a different perspective on it.
- bheadmaster 4y ago> I don't know of a different motive for inheritance. Code reuse? You have a base class that does a bunch of stuff, and you want to add a single thing. If there wasn't any motive for inheritance without polymorphism, then all methods in C++ would be virtual, wouldn't they?