0% found this document useful (0 votes)
3 views4 pages

IOOM Assignment - 2

The document outlines an assignment for implementing various C++ programs involving class design, inheritance, and constructors. It includes tasks for creating classes such as Device, Student, Person, Animal, and BankAccount, with specific attributes and methods, as well as requirements for implementing copy constructors. Additionally, it emphasizes the need for separate compilation files and the creation of a makefile for code compilation and linking.

Uploaded by

Nikhil Ruhela
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)
3 views4 pages

IOOM Assignment - 2

The document outlines an assignment for implementing various C++ programs involving class design, inheritance, and constructors. It includes tasks for creating classes such as Device, Student, Person, Animal, and BankAccount, with specific attributes and methods, as well as requirements for implementing copy constructors. Additionally, it emphasizes the need for separate compilation files and the creation of a makefile for code compilation and linking.

Uploaded by

Nikhil Ruhela
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/ 4

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)

●​ The class should have a default constructor, a parameterized constructor, and a


copy constructor.

Implement two versions of the copy constructor:

●​ 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:

●​ employeeId (int) and


●​ department (string).

Create another derived class Manager from Employee that 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.

2.​ Implement a class Box that contains:

length (int)
width (int)
height (int)

●​ The class should have a default constructor, a parameterized constructor, and a


copy constructor.

Implement two versions of the copy constructor:

●​ 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”.

Create an object of each subclass and call make_sound().

2.​ Implement a class Box that contains:

length (int)
width (int)
height (int)

●​ The class should have a default constructor, a parameterized constructor, and a


copy constructor.

Implement two versions of the copy constructor:

●​ 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:

●​ A constructor to initialize the book's details.


●​ A copy constructor to perform deep and shallow copying.

You might also like