What is meant by polymorphism in c++? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

What is meant by polymorphism in c++?

28th Jul 2017, 2:32 AM
ABI NANDHU
ABI NANDHU - avatar
3 Answers
+ 3
Polymorphism is a big word with a seemingly complex meaning, however the concept is down right genius! Infact it is a requirement for any programming language to be considered as Object Oriented. Basically, it's the ability to have a base class with a method and define the method according to each specific subclass of the base class. For example, you may have a base class of 'food'. Every food will have a consume() method, so the parent class should have a consume method. But some foods will be slurped, bitten, swallowed, sipped, etc. These different ways of being consumed are specific to the type of food, so each and every food class will have to define the method of consume according to what that specific food is. Making some methods required saves you from remembering each and every method when a new class is made, you simply have to define the methods and boom. Also, you can call on any method on any subclass and know that it will run that method because the parent class contains that method. I hope this answers your question.
28th Jul 2017, 3:27 AM
Imran Din
Imran Din - avatar
+ 1
water type ice in solid vapour in gaseous normal ( form ) liquid
28th Jul 2017, 2:34 AM
tabish
tabish - avatar