0% found this document useful (0 votes)
5 views2 pages

Inheritance Program

The document outlines the implementation of multilevel and multiple inheritance programs in C++. It includes examples of class hierarchies for managing personal information, publications, school staff, and phone specifications using multilevel inheritance, as well as student performance evaluation and media skills using multiple inheritance. Each example emphasizes the combination and display of data from derived classes through a single object.

Uploaded by

rarham770469
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views2 pages

Inheritance Program

The document outlines the implementation of multilevel and multiple inheritance programs in C++. It includes examples of class hierarchies for managing personal information, publications, school staff, and phone specifications using multilevel inheritance, as well as student performance evaluation and media skills using multiple inheritance. Each example emphasizes the combination and display of data from derived classes through a single object.

Uploaded by

rarham770469
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

MULTILEVEL Inheritance Programs

1. Create a base class Person that stores personal information such as name and age. Include
member functions to input and display these details. Derive a class Employee from
Person. This class should store employee-related information such as employee ID and
salary. Include functions to input and display employee details. The Employee class
should inherit the personal information from the Person class. Further derive a class
Manager from Employee. This class should contain additional information such as
department name and designation. Include member functions to input and display
manager details. Use multilevel inheritance to show how data from all three classes
(Person, Employee, and Manager) can be combined and displayed through the Manager
class.

2. Create a base class Publication that stores publication-related information such as


publisher name and publication year. Include member functions to input and display
these details. Derive a class Book from Publication. This class should contain additional
information related to books, such as book title and number of pages. Include functions to
input and display book information. The Book class should inherit publication details
from the Publication class. Further derive a class EBook from Book. This class should
store electronic book details such as file size and file format (for example PDF, EPUB, or
DOCX). Include member functions to input and display complete eBook information.
Use multilevel inheritance to show how publication details, book information, and eBook
properties are combined in a single program. Display all information through the EBook
class object.
3. Create a base class School that stores school-related information such as school name and
school address. Include member functions to input and display these details. Derive a
class Teacher from School. This class should store teacher-related information such as
subject specialization and qualification. Include member functions to input and display
teacher details. The Teacher class should inherit school information from the School
class. Further derive a class Principal from Teacher. This class should contain principal-
related information such as office room number and years of experience. Include member
functions to input and display principal details. Use multilevel inheritance to demonstrate
how data from the School, Teacher, and Principal classes can be combined and displayed
through a single object of the Principal class.
4. Create a base class Phone that stores basic phone information such as model number and
company name. Include member functions to input and display these details. Derive a
class Smartphone from Phone. This class should contain smartphone-related information
such as RAM size and internal storage capacity. Include functions to input and display
smartphone details. The Smartphone class should inherit the phone information from the
Phone class. Further derive a class Gaming Phone from Smartphone. This class should
store gaming phone specifications such as cooling system type and screen refresh rate.
Include member functions to input and display complete gaming phone information. Use
multilevel inheritance to demonstrate how data from all three classes (Phone, Smart
Phone, and Gaming Phone) can be combined and displayed using a single object of the
Gaming Phone class.
Multiple Inheritance Programs

1. Create a simple C++ program using multiple inheritance to evaluate a student’s overall
performance based on academics and sports. Design a class Academic that stores marks
of a student in different subjects (e.g., English, Math, and Computer Science). Design
another class Sports that stores the student’s sports score. Create a derived class Result
that inherits from both Academic and Sports. The Result class should score by adding
academic marks and sports score. Display the final performance result of the student.
2. Design a system for a media organization where different types of skills are modeled
using classes. Create a class Writer that contains writing-related skills such as writing
speed, language command, and ability to write articles or scripts. Create another class
Photographer that contains photography-related skills such as camera handling, photo
editing skills, and experience level in photography. Create a derived class Journalist that
inherits from both Writer and Photographer, representing a professional who can both
write news stories and capture news photographs. The Journalist class should include a
function to display combined skills and calculate overall performance based on writing
and photography abilities. Finally, demonstrate the working of all classes in the main ()
function by creating an object of Journalist and displaying its complete profile.
3. Create a class Engine that stores engine-related information such as engine number,
engine power, and fuel type. Include member functions to input and display engine
details. Create another class Body that stores body-related information such as body type
and vehicle color. Include functions to input and display body details. Create a derived
class Car that inherits from both Engine and Body using multiple inheritances. Add
additional attributes in the Car class such as car model and price. Write member functions
to input and display complete car information by combining features of both base classes.

You might also like