Unit 3 - Week2
Unit 3 - Week2
Lab Program
Develop a C++ program to find out the payroll system using single inheritance for multiple
number of employees.
Create a C++ program to demonstrate Hybrid Inheritance. Define a base class Shape with a
virtual function calculate_area(). Derive two classes Rectangle and Circle from Shape using
single inheritance. Further, derive a class Cylinder from both Rectangle and Circle using
multiple inheritance. Implement necessary functions to calculate the area of the rectangle,
circle, and the volume of the cylinder.
Abstract Class:
1.Create an abstract class Vehicle with pure virtual functions startEngine() and
stopEngine().Derive two classes Car and Motorcycle from Vehicle. Implement the
functions to display a message indicating the engine status. Additionally, implement a
function in the base class to demonstrate dynamic memory allocation for an array of
pointers to Vehicle objects.
2.Design an abstract class Shape with pure virtual functions calculateArea() and
displayInfo(). Derive three classes Circle, Rectangle, and Triangle from Shape.
Implement the functions to calculate the area and display information for each shape.
Create an array of pointers to Shape objects and demonstrate polymorphism.
3.Create an abstract class Person with pure virtual functions displayDetails() and
calculateSalary(). Derive two classes Employee and Manager from Person. Implement
the functions to display details and calculate the salary for each category. Create an
array of pointers to Person objects and demonstrate polymorphism.
Friend Function
Sum of n number of odd natural numbers by using friend class in C++.
Friend Function for Adding Two Complex Numbers
Friend Function for Calculating Average of 5 marks
Write a c++ program to Add members of two different classes using friend functions
Inline Function
C++ Program to demonstrate inline functions to perform
get(),sum(),difference(),product(),division() and classes
2.Write a C++ Program to display the reverse of a number using the Inline function.
Activity Diagrams: