IOOM Assignment - 2
IOOM Assignment - 2
Instructions:
1. Please do not write the entire code within a single file. You need to follow a separate
compilation. If the program design necessitates a single class, it is recommended to
employ three distinct files: one for the class declaration, another for the class definition,
and a third for the driver program containing the main function.
2. Create a makefile for compiling and linking the code.
Batch 1:
1. Design and implement a C++ program to define a base class Device with the private
attribute brand.
● Create a subclass Phone that adds an attribute model.
● Create another subclass Smartphone that adds a method show_details() to
display brand and model.
● Create an object of the Smartphone class and display the details of it.
2. Design and implement a C++ program to define a class Student with the following
private attributes:
● name (string)
● age (int)
● marks (float)
● Define a copy constructor for the Student class that performs a deep copy and shallow
copy when a new object is created by copying another Student object. Ensure that both
the original and the copied object can independently modify their values without affecting
each other.
Batch 2:
1. Design and implement a C++ program to define a class named Student with the
following attribute:
name (String)
● Create a class Athlete with an attribute sport.
● Create a class SportsStudent that inherits from both and has a method display()
to print name and sport.
● Create an object and call display().
2. Implement a class Box that contains:
length (int)
width (int)
height (int)
● One that performs a shallow copy (i.e., copy all attributes directly).
● One that performs a deep copy (i.e., create new copies for dynamic memory, if
applicable).
Batch 3:
1. Design and implement a C++ program to define a class Person with the following private
attributes:
● name (string)
● age (int)
Create a derived class Employee that inherits from Person and adds:
● teamSize (int).
Implement constructors and methods in each class to initialize and display attributes.
Implement multilevel inheritance by creating a Manager object and displaying all the
information.
length (int)
width (int)
height (int)
● One that performs a shallow copy (i.e., copy all attributes directly).
● One that performs a deep copy (i.e., create new copies for dynamic memory, if
applicable).
Batch 4:
1. Design and implement a C++ program to define a class named Animal with the method
make_sound().
● Create a subclass Cat that overrides make_sound() to print “Meow”.
● Create another subclass Dog that overrides make_sound() to print “Bark”.
length (int)
width (int)
height (int)
● One that performs a shallow copy (i.e., copy all attributes directly).
● One that performs a deep copy (i.e., create new copies for dynamic memory, if
applicable).
Batch 5:
1.Design and implement a C++ program to define a base class BankAccount with attributes:
account_number, balance and methods: deposit(), withdraw(),display_balance().
Create subclasses SavingsAccount and CurrentAccount.
Create objects of both subclasses and access display the balance and withdraw
methods.
2. Implement a class Book that has:
● title (string)
● author (string)
● price (double)
Implement the following: