Feb-18-2017, 04:31 AM
Feb-18-2017, 10:40 AM
(Feb-18-2017, 04:31 AM)hsunteik Wrote: [ -> ]what is the different between inheritence and instanciation?
They both have same function and uses.
so how are the two used differently?
Totally different things.
"inheritance" is defining a new class by modifying/specializing the "base" class. For instance you have a class
Mammal
, from which you derive a class Dog
, from which you derive a class Labrador
. So Labrador
inherits from Dog
which inherits from Mammal
."instanciation" is creating objects ("instances") of the class. Instances of
Labrador
are called "Fido", "Snoopy", etc... Note that Fido, is a Labrador, but is also a Dog and a Mammal, so methods defined for Mammal are also available for Dog and Labrador (but of course these class can override said methods to provide their own).