Why is the key idea of ​​OOP polymorphism?

In C ++ Primer, the author wrote: "The key idea of ​​OOP is polymorphism." I'm not sure I understand what the author meant. What about other important things: Abstract, Inheritance, etc. Can someone clarify this please?

Edit: I do not ask: "What is polymorphism." I ask: "Why is polymorphism the key to OOP"? Why is not inheritance the key?

+3
source share
3 answers

I am not sure if this is the key to OOP. This is just an opinion.

I think there are four keys: abstract data types, encapsulation, inheritance, and polymorphism. They belong to each other.

. ADT - , . ADT. .

if, switch case. , , ; .

+2

, :

  • B A, B A ---- > . , Inheritance .

  • A * something *, A rome * something *, . , .

  • : - , (). Child Abstract , , .

, , , - .

+1

In general, the idea of ​​creating objects (with their fields, methods, etc.) that can have more than one class of (abstract) classes, implemented interfaces, etc.

And you would have your answer in a few seconds if you first asked Google, Wikipedia and so on;)

0
source

All Articles