Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 7

Object Oriented Programming Lab

CSL 210

Lab Journal
Lab # 9

Department of Computer Sciences


BAHRIA UNIVERSITY, ISLAMABAD
Lab Title

Objectives:

Following programming skills will be acquired in this lab:

 To understand class inheritance.

 To understand the use of protected class members.

 To practice implementation of a base and derived class.

 To understand multiple inheritance.

Tools Used:

Visual Studio

Submission Date:
Evaluation: Signatures of Lab Engineer:

Task # 1:

Write a program that defines a shape base class with a constructor that gives value to width and height. Then
define two derived classes triangle and rectangle, that calculate the area of the shape. In the main,
define two variables a triangle and a rectangle and then compute their area.

Procedure/Program:
Result/Output:
Task # 2:

Exercise 9.2 Write a class to represent a 2D point. Derive a class from it to represent a 3D point. Use objects of
the derived classes to find distance between two points

Procedure/Program:

Result/Output:

Task # 3:

Create a class called Employee whose objects are records for an employee. This class will be a derived class of
the base class Person. An employee record has an employee's name (inherited from the class Person),
an annual salary represented as a single value of type double, a year the employee started work as a
single value of type int and a national insurance number, which is a value of type String. Your class
should have a reasonable number of constructors and access functions, as well as a print function.
Write a driver to fully test your class definition.

Procedure/Program:
Result/Output:

You might also like