Using multilevel inheritance
Multilevel inheritance is where one class inherits another single class. The inheriting class in turn is inherited by a third class, as shown in the following diagram:

In the preceding diagram, you can see that class B inherits class A and class C, in turn, inherits class B.
The following statement defines multilevel inheritance, where the Result
class inherits the Marks
class and the Marks
class, in turn, inherits the Student
class:
class Student: class Marks(Student): class Result(Marks):
In the preceding statement, Student
is the base class and the Marks
class inherits the Student
class. The Result
class inherits the Marks
class. Consequently, the instance of the Result
class can access the methods and variables of the Marks
class, and the instance of the Marks
class can access the methods and variables of the Student
class.
Getting ready
To understand the concept of multilevel inheritance, let's create an application that will prompt the user to enter...