+ 1
What is meant by polymorphism in c++?
3 Respuestas
+ 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.
+ 1
water
type
ice in solid
vapour in gaseous
normal ( form ) liquid