Inheritance Questions in C++
Below are four questions on inheritance in C++. Each question corresponds to one type of
inheritance. These are program-oriented questions.
1■■ Single Inheritance
Create a base class Person with data members name and age and a member function display().
Derive a class Student that adds data member rollNo and a function showDetails(). Write a C++
program to input and display all details of a student using single inheritance.
2■■ Multiple Inheritance
Define a class Sports with a member sportsMarks, and another class Academics with a member
academicMarks. Derive a class Result from both Sports and Academics to calculate and display the
total marks of a student using multiple inheritance.
3■■ Multilevel Inheritance
Design three classes: - Vehicle (base) with data brand. - Car (derived from Vehicle) with data
model. - ElectricCar (derived from Car) with data batteryCapacity. Write a program that uses
multilevel inheritance to input and display all these details.
4■■ Hierarchical Inheritance
Create a base class Employee with data members empID and name. Derive two classes: Manager
(with teamSize) and Developer (with programmingLanguage). Demonstrate hierarchical inheritance
by creating objects of both Manager and Developer and displaying their details.