Can I say polymorphism analogues to overloading(not litrally of course) if so how? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 26

Can I say polymorphism analogues to overloading(not litrally of course) if so how?

18th Aug 2018, 4:40 PM
Byk
5 Answers
+ 3
there is quite a difference between polymorphism and overloading. overloading makes it possible for a class to use more than one method with the same name as long as they differ in their arguments. polymorphism does not only refer to one or more methods in one class. it refers to parental and child classes, which use methods with the same name. sometimes they even use them in different ways (override). so it is not really possible to use these words as analogues.
18th Aug 2018, 9:23 PM
[No Name]
[No Name] - avatar
+ 2
Polymorphism is a way to call methods of different children classes through virtual methods of one parent class. Your module could not have whole information about children types. The only reference to parent type is enough to make correct calls. You have to provide all available function overloads to be able call them. There is no way to get different implementations through one call by overloading feature.
19th Aug 2018, 3:39 PM
Sergey Ushakov
Sergey Ushakov - avatar
+ 1
B11010 overloading and overriding is done for function...that is the only similarity is between both of them... One require different type or number of argument where as riding require same number of argument...
18th Aug 2018, 5:06 PM
Ketan Lalcheta
Ketan Lalcheta - avatar
0
هلا
19th Aug 2018, 11:46 AM
دولار يماني
دولار يماني - avatar
0
😖
19th Aug 2018, 1:17 PM
Achraf
Achraf - avatar