Polymorphism | Sololearn: Learn to code for FREE!
¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita
+ 1

Polymorphism

who can help me understand polymorphism ?

27th Jun 2020, 6:48 PM
Yvon Richel Désir Bemba
Yvon Richel Désir Bemba - avatar
4 Respuestas
+ 10
Avinesh Oh wow... After reviewing many of the really bad answers in those posts, I can understand why people are so confused about polymorphism. This is a case where community answers may not be the best source. Many of the answers are terrible or wrong. Some answers are decent but only scratch the surface or take a hard left turn from good to bad. I will say that the best of those posts shared are the collective answers posted in the last link. https://www.sololearn.com/Discuss/149024/?ref=app I especially liked the answer posted by @Simon Lepasteur ---- "Usually, when we speak about polymorphism in c++, we don't mean function overloading or generic programming, we mean polymorphism via subtyping. Therefore it is the possibility of a method of an object to have different behaviour depending on the "real" type of the object." ---- This is especially true in strongly typed languages like C# and Java where interfaces are highly used to decouple dependencies from concrete references.
28th Jun 2020, 1:20 AM
David Carroll
David Carroll - avatar
+ 5
David Carroll ūüĎŹūüĎŹūüĎŹūüĎŹūüĎŹsuperb
28th Jun 2020, 1:30 AM
BUCHUPALLI VIMALA REDDY
BUCHUPALLI VIMALA REDDY - avatar
+ 1
David Carroll polymorphism via subtyping is just one of the many forms of polymorphism. Polymorphism is a polymorphic concept.(ūüėā) and I think method overloading is a form of polymorphism. Yvon Richel D√©sir Bemba In general, polymorphism means "many forms". It is the ability for an object, method, parameter etc to have many forms. Some animals are domestic, some are wild. Some are herbivores, some are carnivores. Some are even both. Animal is a polymorphic type. A dog is a polymorphic object. It is both an animal and a carnivore. All animals reproduce but they do so differently. Therefore Animal.reproduce is a polymorphic method. It is that simple but there is more to polymorphism in OOP. There are interfaces, inheritance and other concepts that aid polymorphism.
28th Jun 2020, 12:24 PM
Ore
Ore - avatar