What is the difference between inheritence and override? | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
+ 2

What is the difference between inheritence and override?

8th Sep 2016, 2:03 AM
Rojenn Claire Patigdas
Rojenn Claire Patigdas - avatar
3 Réponses
+ 2
If you don't know, please don't reply, otherwise people will think the question has been answered. When a class inherits from another class (they are called the derived class and the base class respectively), the derived class gets access to all public and protected attributes and methods of the base class. The derived class can redefined its own implementation of a method of the base class that will override it. For example, class B inherits from class A, and class A has a foo() method. In the definition of class B, we can redefine a foo() method with a different behavior (overriding it), and this is this method that will be called when calling foo() on a B object. If you don't override foo(), calling foo() on a B object will call the inherited foo() of class A.
8th Sep 2016, 10:02 AM
Zen
Zen - avatar
+ 1
I don't know. I'm so sorry
8th Sep 2016, 2:04 AM
Valerie Castillo
Valerie Castillo - avatar
- 2
idk too
8th Sep 2016, 2:05 AM
Andrea Hechanova