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

University of Central Punjab: Object Orient Programing

The document provides instructions for Object Oriented Programming Lab 11. Students are asked to complete two tasks: 1) Create classes for Person and Student with attributes and methods for inputting and displaying data. 2) Demonstrate multi-level inheritance by creating classes for Vehicle, FourWheeler, and Car and invoking methods from each class through a Car object. Sample outputs are provided for both tasks.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views2 pages

University of Central Punjab: Object Orient Programing

The document provides instructions for Object Oriented Programming Lab 11. Students are asked to complete two tasks: 1) Create classes for Person and Student with attributes and methods for inputting and displaying data. 2) Demonstrate multi-level inheritance by creating classes for Vehicle, FourWheeler, and Car and invoking methods from each class through a Car object. Sample outputs are provided for both tasks.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

University of Central Punjab

Faculty of Information Technology

Object Orient Programing

OOP LAB 11

Instructions:
• Indent your code.
• Comment your code.
• Use meaningful variable names.
• Plan your code carefully on a piece of paper before you implement it.
• Use single .cpp file for graded lab.

Students are required to complete the following tasks in lab timings.

Task 1

Write a class Person that has the attributes of id, name and address. It has a constructor to initialize, a
member function (getInfo) to input and a member function (showInfo) to display data members.
Create another class Student that inherits Person class. It has additional attributes of roll number and
marks. It also has member function(getEdu) to input and display(showEdu) its data members.

Sample Output

Enter your id: 1


Enter your Name: Usman Khalil
Enter your Address: DHA, Lahore
Enter your Roll no: 25
Enter your Marks: 850

Your personal information is as follows:


Id = 1
Name = Usman Khalil
Address = DHA, Lahore

Your education information is as follows:


Roll no= 25
Marks= 850
Task 2

Suppose we have three classes Vehicle, FourWheeler, and Car. The class Vehicle is the base class, the
class FourWheeler is derived from it and the class Car is derived from the class FourWheeler. Class
Vehicle has a method 'vehicle' that prints 'I am a vehicle', class FourWheeler has a method
'fourWheeler' that prints 'I have four wheels', and class Car has a method 'car' that prints 'I am a car'.
So, as this is a multi-level inheritance; we can have access to all the other classes methods from the
object of the class Car. We invoke all the methods from a Car object and print the corresponding
outputs of the methods.

Sample Output

I am a car
I have four wheels
I am a vehicle

You might also like