0% found this document useful (0 votes)
12 views3 pages

CTUC103 - Practical Assignment-5

The document outlines a practical assignment for a B.Sc. IT course focusing on Object-Oriented Programming concepts in C++. It includes tasks such as implementing multi-level inheritance, virtual functions, polymorphism, function overloading, and operator overloading in C++. Each task requires writing specific programs to demonstrate the application of these concepts in various scenarios.

Uploaded by

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

CTUC103 - Practical Assignment-5

The document outlines a practical assignment for a B.Sc. IT course focusing on Object-Oriented Programming concepts in C++. It includes tasks such as implementing multi-level inheritance, virtual functions, polymorphism, function overloading, and operator overloading in C++. Each task requires writing specific programs to demonstrate the application of these concepts in various scenarios.

Uploaded by

lakshrajsinh188
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Smt.

Chandaben Mohanbhai Patel Institute of Computer Applications


B.Sc. IT Semester - II
CTUC103 - Introduction to Object Oriented Programming
Practical Assignment – 5
Implementation of Object-Oriented Programming Concepts in C++: Inheritance,
Virtual Function, Polymorphism

1  Write a program for Multi-Level and Virtual Base Class Inheritance.


 Create a superclass Person to input Name.
 Create an intermediate class Student inheriting Person, to input
Roll_Number.
 Create another intermediate class Teacher inheriting Person, to input
Department_Name.
 Create a derived class Library, inheriting both Student and Teacher, to
input No_of_books issued.
 Implement getdata() and putdata() in all classes.
 User the concept of a virtual base class to avoid ambiguity and display all
details.
2  Write a program to Simple Interest calculation using Runtime polymorphim
and Virtual Function:
 Create a base class Bank with a function to calculate simple interest – SI
at 7.2%.
 Create a derived class HDFC_Bank, overriding the function to calculate
SI at 7.5%.
 Create another derived class AXIS_BANK, overriding the function to
calculate SI at 8.5%.
 Solve this program using Run Time Polymorphism (Virtual Function).
3  Write a program to calculate road trip by taking ₹12/KM by using member
function in a base class Traveler. Now, calculate road trip by taking ₹15/KM by
using member function in a derive class Sedan_Car. Again calculate road trip
by taking ₹18/KM by using member function in a derive class SUV_Car. Solve
this program by using Run Time Polymorphism Virtual function.
4  Write a program to find Area of different shapes by using member function in
a base class Shape. Now, calculate Area of Rectangle by using member function
in a derive class Rectangle. Again, calculate Area_of_Circle by using member
function in a derive class Circle. Again, calculate Area_of_triangle by using
member function in a derive class Triangle. Solve this program by using Run
Time Polymorphism “Pure Virtual function”.
 [Area of Rectangle = L * W, Area of Circle = Pi*r*r, Area of Triangle = (h*b)/2]

1
5 Write a Program for Function Overloading (Addition of Different Types of
Numbers):
Overload functions to perform:
 Addition of two integer numbers.
 Addition of three integer numbers.
 Addition of two float numbers.
 Addition of three float numbers.
6  Write a program to input one number in a base class and one number in a
derived class. Perform basic arithmetic operations by using a member function
in a derived class.
7  Construct a class Month with data members as Month_No. Write down
overloaded operator++ for the increment the month number by one. Write a
member function read() and display() to read a number of month and print a
number of next month.
Input: Input:
Enter month number: 8 Enter month number: 12
Output: Output:
Next Month number is: 9 Next Month number is: 1
8 Construct a class Month with data members as Month_No. Write down
overloaded operator- - for the decrement the month number by one. Write a
member function read() and display() to read a number of month and print a
number of next month.
Input: Input:
Enter month number: 8 Enter month number: 1
Output: Output:
Previous Month number is: 7 Previous Month number is: 12
9 Construct a class Week with data members as Week_Day_Number. Write down
overloaded operator ++ for the increment the Week Day number by one. Write
a member function getdata() and showdata() to input a number of Week Day
and print Week Day number of previous day.
Input: Input:
Enter Day number: 5 Enter Day number: 7
Output: Output:
Next Day number is: 6 Next Day number is: 1
10 Construct a class Arithmetic with data member as Number. Write down all the
arithmetic operator overloaded i.e +, -, *, / for basic arithmetic operations. Write
a member function to read() and display() the result of operations performed
on user defined data types.
11 Write a Program to demonstrate unary operator overloading in C++.

2
12 Write a Program to demonstrate unary operator overloading using a friend
function.
13 Write a program to define a class Time with hours and minutes as data
members. Implement a getData() method to accept values for two objects and
use binary operator overloading (+ operator) to add two Time objects. Display
the result in a properly formatted manner.
14 Write a program to define a class Time with hours and minutes as data
members. Implement a getData() method to accept values for two objects and
use a friend function to overload the + operator for adding two time objects.
Display the result in a properly formatted manner.

You might also like