Example
of Inheritance in Python
* In Python lets assume that , one can take
a class A with two variables 'a' and 'b' and a method like method01() in
the given manner .
* Since all the methods are needed by
another class B , one can extend class B from class A .
* If we want some additional members in
object B , for example a variable 'c' and a method in the form of method02() .
These methods are written in object B .
* From this one would remember that class B
can use all the members of both A and B .
* This means that all the variables 'a' ,
'b' , 'c' and the methods method01() and method02() are available to the class
B . This means that all the members of class A are inherited by class B .
<<
FIG >>
* By creating an object of B , one can
access all the members of both the classes A and B that is when an object of
class B is created which is a form of derived class object , from the base
class , one can create another object .
No comments:
Post a Comment