You are on page 1of 3

University of Central Punjab

Faculty of Information Technology

Object Oriented Programming

Lab 09
Topic Classes in C++
The basic purpose of this lab is to revise some preliminary concepts of C++ that has
been covered in the course of Introduction to Computing and Programming
Objective Fundamentals. Its objective is to recall previously learned basic concepts like revision
of arrays, functions and pointers.

Instructions:
• Indent your code.
• Comment your code.
• Use meaningful variable names.
• Plan your code carefully on a piece of paper before you implement it.
• Name of the program should be same as the task name. i.e. the first program should be
Task_1.cpp

Students are required to work in multiple files i.e .h and .cpp

Task 1:
Implement the following class hierarchy.
 Container(Base)
 Rectangle(Derived from Container)
Container class has three properties (length, width). Rectangle class will have an
area function. You have to set values of properties in order to display correct
area for rectangle and you can’t set those values through object of Rectangle

Task 2:
Implement the following class hierarchy.
 Container(Base)
 Cylinder (Derived from Container)
 Sphere (Derived from Container)
Container class has three properties (height, width, radius). Cylinder and Sphere
classes will have a volume function. You have to set values of properties in
order to display correct volume for Cylinder and Sphere and you can’t set those
values through objects of Cylinder and Sphere.
Task 3:
Implement the following class hierarchy.
 Person (base)
 Employee (derived)
Person class has four properties (Name, Age, Address, Phone). Employee class
has the two properties (EmployeeID, Designation). Employee class should have
a display method, which should display the complete information of the
Employee;
 Name
 Age
 Address
 Phone
 EmployeeID
 Designation.

Task 4:
Implement the following class hierarchy.
 Person (Base)
 Student (Derived from Person)
 Teacher (Derived from Person)
Person class has following protected attributes:
 Name
 Age
 Address
 Phone Number
Student class has following private attributes:
 Semester
 Cgpa
Teacher class has following private attributes:
 Qualification
 Experience
Student and Teacher classes will have a display function which display the
complete information of a Student or a Teacher including his name, age, address
and phone number.

You might also like