04-08-2012, 01:02 PM
MULTIPLE INHERITANCE
LAB_11_Multiple_inheritance.docx (Size: 54.01 KB / Downloads: 23)
LAB TASK 1
Write a program to input the record of a student and print on the screen by using multiple inheritance. Create a base class “Student” that stores name, address and roll number of a student.
Student class must have getdata() function to get its data (name, roll no and address of the student) from the user, and also has print() function to display the data.
Create another base class “Marks” that stores marks of the student in three subjects, their total and average marks. Marks class must have inputmarks function to get the marks of the student in three subjects. Then calculate the total marks and average marks in the three subjects. Create another function show_detail() to display the marks in three subjects, total marks and average marks.
Derive a class “Show” from the two base classes described above, the derived class contains show_rec() function to display the complete record of a student. Te output of the program should be like:
LAB TASK 2
Write a program that consists of two classes’ employee and student. Create three other classes: manager, scientist and laborer. Modify manager and scientist so that they inherit from both employee and student classes. The laborer class is inherited only from employee class. The program output should be like this: