When would we use inheritance ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

When would we use inheritance ?

2nd Jul 2017, 12:27 PM
Sushil Ch Ray
3 Answers
0
Use it when you want to highlight 'is-a' relation between the classes. Circle is a Shape? => use inheritance. Also you should use it if you need polimorphysm => define base interface, derive concrete classes and control all of them via single interface.
2nd Jul 2017, 3:38 PM
soman
+ 1
A basic Enemy have some behaviors and values, but there is more enemy types like Ninja and Monster that have it's own behaviors + basic Enemy behaviors
2nd Jul 2017, 1:01 PM
Andrés04_ve
Andrés04_ve - avatar
0
when you need to pass the values of one func to another without declaring them in that func.
2nd Jul 2017, 5:33 PM
CodeXJose
CodeXJose - avatar