Answer the question
In order to leave comments, you need to log in
Is Polymorphism Reverse Inheritance?
Is it correct to think of polymorphism as reverse inheritance?
That is: the ability of an ancestor to apply the fields and methods of a child class?
If not, can you please explain in simple terms + an example?
Thanks in advance!
Answer the question
In order to leave comments, you need to log in
Is this your own definition of reverse inheritance?
The parent class knows nothing about the child methods.
Polymorphism is needed to organize the abstraction layer.
The car has an abstract interface: accelerate, brake, turn. You apply the appropriate methods, and under the hood, polymorphism occurs depending on which car you are driving: on the internal combustion engine, when accelerating, the damper is moved, the mixture is enriched, it enters the nozzles, the speed increases; in an electric car, the frequency converter increases the frequency of the sinusoid going to the engines, it starts spinning faster ... Then someone came up with a hybrid and everything is much more complicated there, but at the level of the "ancestor" you don’t need to think about all this, thanks to polymorphism we have simple understandable methods that have descendants implemented in their own way.
Apparently we are talking about (dependency inversion principle, DIP) - The principle of dependency inversion
The terms that you operate with (reverse inheritance) are not known. And it's hard to understand what the actual question is.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question