0% found this document useful (0 votes)
7 views2 pages

Lab 10

This document outlines instructions for a lab on Object Oriented Programming focusing on inheritance. It includes the creation of multiple classes with specific functionalities, such as displaying messages and calculating areas, while adhering to coding standards to avoid memory leaks and ensure proper use of constructors and accessors. Additionally, it involves calculating total and average marks for students in different subjects through class inheritance.

Uploaded by

hirrah21
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)
7 views2 pages

Lab 10

This document outlines instructions for a lab on Object Oriented Programming focusing on inheritance. It includes the creation of multiple classes with specific functionalities, such as displaying messages and calculating areas, while adhering to coding standards to avoid memory leaks and ensure proper use of constructors and accessors. Additionally, it involves calculating total and average marks for students in different subjects through class inheritance.

Uploaded by

hirrah21
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/ 2

Object Oriented Programming

Lab 10
Topic(s): Inheritance
IMPORTANT INSTRUCTIONS:

Please keep in mind the following points while coding. Violating any of these will result in
credit deduction.

• There should be no memory leakage in your class. There should be no dangling


pointers.
• Make functions, objects, variables as constant wherever possible.
• Create Default, Parameterized and Copy Constructor whether mentioned or not.
• Create Setters and Getters for all attributes.
• Follow the appropriate naming conventions as explained in class.
• Submit your files following the submission format explained in class.

Question No. 01

You have to Create three classes:


Class Vehcile:
Vehicle Class will contain a display() function, which will say "This is a Vehicle".
Class Car:
Car Class will derive the Vehicle Class and overwrite its display() function. it will say "This
is a Bike".
Class Bike:
Bike Class will derive the Vehicle Class and overwrite its display() function. it will say
"This is a Car".

Question No. 02
Create two classes:
BaseClass
The Rectangle class should have two data fields-width and height of int types. The class
should have display()method, to print the width and height of the rectangle separated
by space.
DerivedClass
The RectangleArea class is derived from Rectangle class, i.e., it is the sub-class of
Rectangle class. The class should have read_input() method, to read the values of width
and height of the rectangle. The RectangleArea class should also override the display()
method to print the area (width*height) of the rectangle.
Question No. 03

We want to calculate the total marks of each student of a class in Physics,Chemistry


and Mathematics and the average marks of the class. The number of students in the
class are entered by the user. Create a class named Marks with data members for roll
number, name and marks. Create three other classes inheriting the Marks class,
namely Physics, Chemistry and Mathematics, which are used to define marks in
individual subject of each student. Roll number of each student will be generated
automatically.

You might also like