C++: Inheritance |Hierarchical inheritance

Example:1
Write a C++ program to declare a class named student with attributes as roll and name. Declare another class named physical with attributes as age, height and weight. Declare another class named marks with attibutes as m1, m2, m3, total, per and grade.
The classes physical and marks are the derived class of the class student. Take input for the details and display them.

code

Output:

 

Example:2
Write a C++ program to declare a class named employee with attributes as employee number and name. Declare another class named office with attributes as department number, department name and designation. Declare another class named salary with attributes as basic salary, hra, da, ta, cca, pf, it and net.
The classes office and salary are the derived class of the class employee. Take input for the details and display them.

code

Output: