Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (1 vote)
58 views4 pages

Lab Report 5

This document summarizes Muhammad Saim Ashraf's lab on object oriented programming concepts in C++. It covers function overloading, constructors, constant keywords, classes, objects, and more. Examples include calculating area using function overloading, incrementing object counters, accessing private class members, and defining a Date class with different constructors and member functions. The lab assessment focuses on constructor and function overloading, classes, objects, and constant objects.

Uploaded by

Saim Ashraf
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 (1 vote)
58 views4 pages

Lab Report 5

This document summarizes Muhammad Saim Ashraf's lab on object oriented programming concepts in C++. It covers function overloading, constructors, constant keywords, classes, objects, and more. Examples include calculating area using function overloading, incrementing object counters, accessing private class members, and defining a Date class with different constructors and member functions. The lab assessment focuses on constructor and function overloading, classes, objects, and constant objects.

Uploaded by

Saim Ashraf
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/ 4

OBJECT ORIENTED PROGRAMMING

Lab # 05 OOP

MUHAMMAD SAIM ASHRAF

Names

FA21-BEE-128
Registration
Numbers

Class 3A (BEE)

Instructor’s Name DR RIAZ HUSSAIN

Lab Assessment
Post Lab Total
Pre-Lab In-Lab
Data Presentation Data Analysis Writing Style
Constructor and Function Overloading

4.1:- In this first example we are just going through some


basics of function overloading in which we made functions
with same name but gave them different arguments so we can
over load

LINK: https://onlinegdb.com/5SF_PKOvY

4.2:- In this example we are learning different types of


constructer in which we are using the same name but giving
them different arguments to distinguish.

LINK: https://onlinegdb.com/FJhX9Wuiw

4.3:- In this this example we are learning about constant


keyword the purpose of this is so our function can’t change
the value of integer by pass by reference method.

LINK: https://onlinegdb.com/hQ5AEWFPe

5.1:- In this first task we just had to make a program which


calculated the area of specific shape for this we just made a
single name function but over loaded it by giving it different
parameters so it can calculate different areas.

Link: https://onlinegdb.com/3YqSWajre
5.2:- So in this I have created two objects of Counter class.
Written a cout statement in constructor and then checked
whether that statement appear when two object are created.
Then increment object 1, 3 times and increment object 2, 4
times and display their count values.
Link: https://onlinegdb.com/cMelnGefV9

5.3:- In this task I have created a class race with 3 private


data members then I have to make the program such way that
I can access those private data member and can initialize them
with some values and print it for this I make a public
overloaded function which can access them easily

Link: https://onlinegdb.com/R34PfWxgv

5.4:- In this I was asked to Write a definition of a distance


class as shown in the example 4.2 above. Make all the
appropriate function constant. Include a constant data
member called id of integer type, Create two object constant
and non-constant. Assign values and display them from this I
find out that
1:-
Any attempt to change the data member of const objects
results in a compile-time error.
2:-
If the function is non-constant, then the function is allowed to
change values of the object on which it is being called.

Link: https://onlinegdb.com/9bV8IzRN4
6.1:- In this I have to Write a definition of class named Date
that contains three elements the month, the day of the
month, and the year, all of type int.
I have created three constructor for it, a function to print data
and a function for set data.
Link: https://onlinegdb.com/Zh1IIer7U

You might also like