SlideShare a Scribd company logo
1 of 73
CLASSES
 Creating Objects:
Program#01:
Write a program that declares a class with one integer data member and two
member functions in() and out() to input and output data in data member.
Program#02:
Write a class Marks with three data members to store three marks. Write
three member functions
1)in() to input marks,
2)sum() to calculate and return the sum and
3) avg() to calculate and return the average marks
 Defining Member Functions Outside Class:
Program#01:
Write a program that declares a class with one integer data member and two
member functions in() and out() to input and output data in data member.
Program#02:
Write a class Array that contains an array of integers to store five values. It
also contains the following member functions:
1. The fill() function is used to fill the array with the values from the user.
2. The display() function is used to display values of array.
3. The max() function shows the maximum value in the array.
4. The min() function shows the minimum value in the array.
NOTE: All member function should be defined outside the class.
CONSTRUCTOR & DESTRUCTOR
 Constructor:
Program#1:
Write a class that has the displays a simple message on the screen whenever
an object of that class is created.
Program#2:
Write a Number class that contains two integer data members which are
initialized to 100 when an object is created. It has a member function avg()
that displays the average of data members.
 Passingparameters to constructor:
Program#1:
Write a program that passes parameter to constructor.
Program#2:
Write a program that passes parameter to constructor and constructor also
initializes its all attributes.
 Constructor Overloading:
Program#1:
Write a class OVER that has num and ch as data members. A constructor with
no parameters initializes num to 0 and ch to ‘x’. A constructor with two
parameters initializes data members with the given values and member
function show() displays the values of data members.
Program#2:
Write a class Book that has attributes for pages, price and title. It has two
functions to input the values and display the values. Create three objects
(b1,b2 and b3) of the class and input values.
 Destructor:
Program#1:
Write a program that demonstrate the use of Destructor.
Program#2:
Write a class Travel that has the attributes of kilometers and hours. A
constructor with no parameter initializes both data members to 0. a member
function get() inputs the values and function show() display the values. It has
the member function add() that takes an object of type Travel to add the
kilometers and hours of calling object and the parameter.
 Returning Objects from Member Functions:
Program#1:
Write a class Travel that has the attributes of kilometers and hours. A
constructor with no parameter initializes both data members to 0.
Program#2:
Write a class Travel that has the attributes of kilometers and hours. A
constructor with no parameter initializes both data members to 0.
STATIC DATA MEMBER
 Static Data Members:
Program#1:
Write a program that counts the number of objects created of a particular
class.
Program#2:
Write a program that clears concept of static member function.
FRIEND FUNCTIONS
 Friend Functions:
Program#1:
Write a program that demonstrate the use of Friend Function.
FRIEND CLASSES
 Friend Classes:
Program#1:
Write a program that demonstrates the use of Friend Classes.
STATIC FUNCTIONS
 Static Functions:
Program#1:
Write a program that demonstrate the use of Static Functions
.
Program#2:
Write a program that counts the number of objects created for a particular
class. The program must be able to display the results even if no object is
created so far.
OPERATOR OVERLOADING
 Operator Overloading:
Program#1:
Write a program that overloads increment operator to work with user-defined
objects.
Program#2:
Write a program that overloads binary addition operator +.
LAB MANUAL 2019
Subject:
Object Oriented Programming
Submitted By:
Hira Kanwal (279)
Submitted To:
Mam Lubna Meer
Submitted On:
9th May,2019
CONTENTS:
Classes
Constructor & Destructor
Static Data Member
Friend Function
Friend Classes
Static Function
Operator Overloading
Inheritance
Polymorphism
Templates
File Handling
INHERITANCE
 Specify a derived class
Program#1:
Write two classes Move and Move2. Move class has attribute of position
which is initialized to zero when an object is created. It also has a member
functions forward() which increments the value of position by 1 and show()
function to display the value of position.Move2 class is a derived class and has
a member function backward() to decrement the value of position by 1.
 AccessingConstructor of parent Class:
Program#1:
Write a program in which derived class access the constructor of parent class.
 Derived Class Constructor:
Program#1:
Write a program that explains the concepts of execution of constructor in
single inheritance.
Program#2:
Write a program that explains the concepts of derived class constructor in
inheritance.
 Function Overriding:
Program 1:
Write a program that explains concept of function overriding in inheritance.
Program#2:
Write a program that explains concept of function overriding.
 TYPES OF INHERITANCE:
 Public Inheritance:
Program#1:
Write a program that declares two classes and defines a relationship between
them using public inheritance.
 Protected Inheritance:
Program#1:
Write a program that declares two classes and defines a relationship between
them using protected inheritance.
 Private Inheritance:
Program#1:
Write a program that declares two classes and defines a relationship between
them using private inheritance.
 Multilevel Inheritance:
Program#1:
Write a program that demonstrate the use of multilevel inheritance.
Program#2:
Write a class Person that has the attributes of id, name and address. It has a
constructor to initialize, a member function to input and a member function to
display data members.
Create 2nd class Student that inherits Person class. It has additional attributes
of roll number and marks. It also has member function to input and display its
data members.
Create 3rd class Scholarship that inherits Student class. It has additional
attributes of Scholarship name and amount. It also has member function to
input and display its data members.
 Multilevel Inheritance with Parameters:
Program#1:

Multiple Inheritance:
Program#1:
Write a program that demonstrate the use of multiple inheritance.
 Constructor in Multiple Inheritance:
 Constructor without Parameters:
Program#1:
Write a program that demonstrates the use of constructor (without
parameter) in multiple inheritance.
 Constructor with Parameters:
Program#1:
Write a program that demonstrates the use of constructor (with parameter) in
multiple inheritance.
 Removing Ambiguity:
Program#1:
Write a program that demonstrate ambiguity in multiple inheritance.
Program#2:
Write a program that removes the ambiguity in multiple inheritance.
 Container Ship:
Program#1:
Write a class Result that has an array of integers as attributes. It has a member
function to input and a member function to display average of array elements.
Create another class Student that inherits Result class. It has additional
attributes of roll number, name and an object of type Result. It has a member
function to input and a member function to display its data members.
POLYMORPHISM &
VIRTUAL FUNCTIONS
 Pointer to objects:
Program#1:
Write a class with an integer data member, a function to input and a function
to display it. Create an object of the class using pointer and calls its member
functions.
 Array of Pointers to Objects:
Program#1:
Write a class that contains an attribute name, a function to input and a
function to display name. Create an array of pointers in which each element
refers to an object of the class.
 Pointers and Inheritance:
Program#1:
Write a program that demonstrate the use of pointer and inheritance.
 Virtual Function:
Program#1:
Write a program that demonstrate the use of virtual function.
 Early Binding:
Program#1:
Write a program that demonstrate the use of early binding.
 Late Binding:
Program#1:
Write a program that demonstrate the use of late binding(dynamic binding).
 Pure Virtual Function :
 Abstract Classes:
Program#1:
Write a program that demonstrate the use of Pure Virtual function.
 Virtual Base Class :
Program#1:
Write a program that demonstrate the use of Virtual Base Class.
Program#2:
Write a program that demonstrate the use of Virtual Base Class.
TEMPLATES
 Function Templates :
Program#1:
Write a program that accepts two numeric values and display the maximum
number. Use function template to find the maximum value.
Program#2:
Write a function template that accepts a value of any type and then display it.
 Class Template:
Program#1:
Write a class template that stores five values of any type in an array.
Program#2:
Write a function template that accepts a value of any type and then display it.
FILE HANDLING
 Writing Data to Formatted Files I/O:
Program#01:
Write a program that writes three characters in a file using formatted I/O.
Program#02:
Write a program that inputs the names of five cities and store them in a file
city.txt.
 Detecting End-of-File:
Program#01:
Write a program that displays all records from city.txt prepared in previous
example.
 Reading Lines From Files:
Program#01:
Write a program that stored five lines of strings in a file and then displays
them on the screen by reading these lines.
 Character I/O:
 Writing Single Character:
Program#01:
Write a program that inputs five characters from the user and stores them in
a file
OOP Programs

More Related Content

What's hot

Variables in C Programming
Variables in C ProgrammingVariables in C Programming
Variables in C Programmingprogramming9
 
Chapter 3 : Balagurusamy Programming ANSI in C
Chapter 3 : Balagurusamy Programming ANSI in C Chapter 3 : Balagurusamy Programming ANSI in C
Chapter 3 : Balagurusamy Programming ANSI in C BUBT
 
Compiler Construction Course - Introduction
Compiler Construction Course - IntroductionCompiler Construction Course - Introduction
Compiler Construction Course - IntroductionMuhammad Sanaullah
 
Control Structures in Python
Control Structures in PythonControl Structures in Python
Control Structures in PythonSumit Satam
 
Managing input and output operations in c
Managing input and output operations in cManaging input and output operations in c
Managing input and output operations in cniyamathShariff
 
Python: Modules and Packages
Python: Modules and PackagesPython: Modules and Packages
Python: Modules and PackagesDamian T. Gordon
 
Templates in C++
Templates in C++Templates in C++
Templates in C++Tech_MX
 
Functions in c++
Functions in c++Functions in c++
Functions in c++Maaz Hasan
 
Functions and modules in python
Functions and modules in pythonFunctions and modules in python
Functions and modules in pythonKarin Lagesen
 
Data Type Conversion in C++
Data Type Conversion in C++Data Type Conversion in C++
Data Type Conversion in C++Danial Mirza
 
FUNCTIONS IN c++ PPT
FUNCTIONS IN c++ PPTFUNCTIONS IN c++ PPT
FUNCTIONS IN c++ PPT03062679929
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in javaTech_MX
 

What's hot (20)

Variables in C Programming
Variables in C ProgrammingVariables in C Programming
Variables in C Programming
 
Chapter 3 : Balagurusamy Programming ANSI in C
Chapter 3 : Balagurusamy Programming ANSI in C Chapter 3 : Balagurusamy Programming ANSI in C
Chapter 3 : Balagurusamy Programming ANSI in C
 
Compiler Construction Course - Introduction
Compiler Construction Course - IntroductionCompiler Construction Course - Introduction
Compiler Construction Course - Introduction
 
Python basics
Python basicsPython basics
Python basics
 
Control Structures in Python
Control Structures in PythonControl Structures in Python
Control Structures in Python
 
Pointer to function 1
Pointer to function 1Pointer to function 1
Pointer to function 1
 
Unit 3
Unit 3Unit 3
Unit 3
 
OOP Assignment 03.pdf
OOP Assignment 03.pdfOOP Assignment 03.pdf
OOP Assignment 03.pdf
 
Managing input and output operations in c
Managing input and output operations in cManaging input and output operations in c
Managing input and output operations in c
 
Python: Modules and Packages
Python: Modules and PackagesPython: Modules and Packages
Python: Modules and Packages
 
Strings in python
Strings in pythonStrings in python
Strings in python
 
Templates in C++
Templates in C++Templates in C++
Templates in C++
 
Functions in c++
Functions in c++Functions in c++
Functions in c++
 
Functions and modules in python
Functions and modules in pythonFunctions and modules in python
Functions and modules in python
 
Data Type Conversion in C++
Data Type Conversion in C++Data Type Conversion in C++
Data Type Conversion in C++
 
Functions in c++
Functions in c++Functions in c++
Functions in c++
 
FUNCTIONS IN c++ PPT
FUNCTIONS IN c++ PPTFUNCTIONS IN c++ PPT
FUNCTIONS IN c++ PPT
 
Python-Inheritance.pptx
Python-Inheritance.pptxPython-Inheritance.pptx
Python-Inheritance.pptx
 
Method overriding
Method overridingMethod overriding
Method overriding
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in java
 

Similar to OOP Programs

.NET Portfolio
.NET Portfolio.NET Portfolio
.NET Portfoliomwillmer
 
Cis 247 all i labs
Cis 247 all i labsCis 247 all i labs
Cis 247 all i labsccis224477
 
Book management system
Book management systemBook management system
Book management systemSHARDA SHARAN
 
Typescript language extension of java script
Typescript language extension of java scriptTypescript language extension of java script
Typescript language extension of java scriptmichaelaaron25322
 
Object Oriented Software Development, using c# programming language
Object Oriented Software Development, using c# programming languageObject Oriented Software Development, using c# programming language
Object Oriented Software Development, using c# programming languageGeorges Abboudeh
 
SE-IT JAVA LAB SYLLABUS
SE-IT JAVA LAB SYLLABUSSE-IT JAVA LAB SYLLABUS
SE-IT JAVA LAB SYLLABUSnikshaikh786
 
Intro To C++ - Class 05 - Introduction To Classes, Objects, & Strings
Intro To C++ - Class 05 - Introduction To  Classes, Objects, & StringsIntro To C++ - Class 05 - Introduction To  Classes, Objects, & Strings
Intro To C++ - Class 05 - Introduction To Classes, Objects, & StringsBlue Elephant Consulting
 
HSc Computer Science Practical Slip for Class 12
HSc Computer Science Practical Slip for Class 12HSc Computer Science Practical Slip for Class 12
HSc Computer Science Practical Slip for Class 12Aditi Bhushan
 
I assignmnt(oops)
I assignmnt(oops)I assignmnt(oops)
I assignmnt(oops)Jay Patel
 
Introduction To C++ programming and its basic concepts
Introduction To C++ programming and its basic conceptsIntroduction To C++ programming and its basic concepts
Introduction To C++ programming and its basic conceptsssuserf86fba
 
Lesson 5 - Getting Input from Users.pdf
Lesson 5 - Getting Input from Users.pdfLesson 5 - Getting Input from Users.pdf
Lesson 5 - Getting Input from Users.pdfROWELL MARQUINA
 
C Programming Lab manual 18CPL17
C Programming Lab manual 18CPL17C Programming Lab manual 18CPL17
C Programming Lab manual 18CPL17manjurkts
 
CBCS 2018 Scheme I sem Lab Manual for 18CPL17
CBCS 2018 Scheme I sem Lab Manual for 18CPL17 CBCS 2018 Scheme I sem Lab Manual for 18CPL17
CBCS 2018 Scheme I sem Lab Manual for 18CPL17 manjurkts
 
Java conceptual learning material
Java conceptual learning materialJava conceptual learning material
Java conceptual learning materialArthyR3
 

Similar to OOP Programs (20)

C++ Lab Maual.pdf
C++ Lab Maual.pdfC++ Lab Maual.pdf
C++ Lab Maual.pdf
 
C++ Lab Maual.pdf
C++ Lab Maual.pdfC++ Lab Maual.pdf
C++ Lab Maual.pdf
 
Intro To C++ - Class 14 - Midterm Review
Intro To C++ - Class 14 - Midterm ReviewIntro To C++ - Class 14 - Midterm Review
Intro To C++ - Class 14 - Midterm Review
 
.NET Portfolio
.NET Portfolio.NET Portfolio
.NET Portfolio
 
Cis 247 all i labs
Cis 247 all i labsCis 247 all i labs
Cis 247 all i labs
 
Book management system
Book management systemBook management system
Book management system
 
Typescript language extension of java script
Typescript language extension of java scriptTypescript language extension of java script
Typescript language extension of java script
 
Object Oriented Software Development, using c# programming language
Object Oriented Software Development, using c# programming languageObject Oriented Software Development, using c# programming language
Object Oriented Software Development, using c# programming language
 
SE-IT JAVA LAB SYLLABUS
SE-IT JAVA LAB SYLLABUSSE-IT JAVA LAB SYLLABUS
SE-IT JAVA LAB SYLLABUS
 
Intro To C++ - Class 05 - Introduction To Classes, Objects, & Strings
Intro To C++ - Class 05 - Introduction To  Classes, Objects, & StringsIntro To C++ - Class 05 - Introduction To  Classes, Objects, & Strings
Intro To C++ - Class 05 - Introduction To Classes, Objects, & Strings
 
HSc Computer Science Practical Slip for Class 12
HSc Computer Science Practical Slip for Class 12HSc Computer Science Practical Slip for Class 12
HSc Computer Science Practical Slip for Class 12
 
Shiny in R
Shiny in RShiny in R
Shiny in R
 
I assignmnt(oops)
I assignmnt(oops)I assignmnt(oops)
I assignmnt(oops)
 
Introduction To C++ programming and its basic concepts
Introduction To C++ programming and its basic conceptsIntroduction To C++ programming and its basic concepts
Introduction To C++ programming and its basic concepts
 
C# p3
C# p3C# p3
C# p3
 
Lesson 5 - Getting Input from Users.pdf
Lesson 5 - Getting Input from Users.pdfLesson 5 - Getting Input from Users.pdf
Lesson 5 - Getting Input from Users.pdf
 
C Programming Lab manual 18CPL17
C Programming Lab manual 18CPL17C Programming Lab manual 18CPL17
C Programming Lab manual 18CPL17
 
CBCS 2018 Scheme I sem Lab Manual for 18CPL17
CBCS 2018 Scheme I sem Lab Manual for 18CPL17 CBCS 2018 Scheme I sem Lab Manual for 18CPL17
CBCS 2018 Scheme I sem Lab Manual for 18CPL17
 
Csharp
CsharpCsharp
Csharp
 
Java conceptual learning material
Java conceptual learning materialJava conceptual learning material
Java conceptual learning material
 

Recently uploaded

SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 

Recently uploaded (20)

SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 

OOP Programs

  • 1. CLASSES  Creating Objects: Program#01: Write a program that declares a class with one integer data member and two member functions in() and out() to input and output data in data member.
  • 2. Program#02: Write a class Marks with three data members to store three marks. Write three member functions 1)in() to input marks, 2)sum() to calculate and return the sum and 3) avg() to calculate and return the average marks
  • 3.
  • 4.  Defining Member Functions Outside Class: Program#01: Write a program that declares a class with one integer data member and two member functions in() and out() to input and output data in data member.
  • 5. Program#02: Write a class Array that contains an array of integers to store five values. It also contains the following member functions: 1. The fill() function is used to fill the array with the values from the user. 2. The display() function is used to display values of array. 3. The max() function shows the maximum value in the array. 4. The min() function shows the minimum value in the array. NOTE: All member function should be defined outside the class.
  • 6.
  • 7. CONSTRUCTOR & DESTRUCTOR  Constructor: Program#1: Write a class that has the displays a simple message on the screen whenever an object of that class is created.
  • 8. Program#2: Write a Number class that contains two integer data members which are initialized to 100 when an object is created. It has a member function avg() that displays the average of data members.
  • 9.  Passingparameters to constructor: Program#1: Write a program that passes parameter to constructor.
  • 10. Program#2: Write a program that passes parameter to constructor and constructor also initializes its all attributes.
  • 11.  Constructor Overloading: Program#1: Write a class OVER that has num and ch as data members. A constructor with no parameters initializes num to 0 and ch to ‘x’. A constructor with two parameters initializes data members with the given values and member function show() displays the values of data members.
  • 12. Program#2: Write a class Book that has attributes for pages, price and title. It has two functions to input the values and display the values. Create three objects (b1,b2 and b3) of the class and input values.
  • 13.  Destructor: Program#1: Write a program that demonstrate the use of Destructor.
  • 14. Program#2: Write a class Travel that has the attributes of kilometers and hours. A constructor with no parameter initializes both data members to 0. a member function get() inputs the values and function show() display the values. It has the member function add() that takes an object of type Travel to add the kilometers and hours of calling object and the parameter.
  • 15.  Returning Objects from Member Functions: Program#1: Write a class Travel that has the attributes of kilometers and hours. A constructor with no parameter initializes both data members to 0.
  • 16. Program#2: Write a class Travel that has the attributes of kilometers and hours. A constructor with no parameter initializes both data members to 0.
  • 17. STATIC DATA MEMBER  Static Data Members: Program#1: Write a program that counts the number of objects created of a particular class.
  • 18. Program#2: Write a program that clears concept of static member function.
  • 19. FRIEND FUNCTIONS  Friend Functions: Program#1: Write a program that demonstrate the use of Friend Function.
  • 20. FRIEND CLASSES  Friend Classes: Program#1: Write a program that demonstrates the use of Friend Classes.
  • 21. STATIC FUNCTIONS  Static Functions: Program#1: Write a program that demonstrate the use of Static Functions .
  • 22. Program#2: Write a program that counts the number of objects created for a particular class. The program must be able to display the results even if no object is created so far.
  • 23. OPERATOR OVERLOADING  Operator Overloading: Program#1: Write a program that overloads increment operator to work with user-defined objects.
  • 24. Program#2: Write a program that overloads binary addition operator +.
  • 25. LAB MANUAL 2019 Subject: Object Oriented Programming
  • 26. Submitted By: Hira Kanwal (279) Submitted To: Mam Lubna Meer Submitted On: 9th May,2019
  • 27. CONTENTS: Classes Constructor & Destructor Static Data Member Friend Function Friend Classes Static Function Operator Overloading Inheritance Polymorphism Templates File Handling
  • 28. INHERITANCE  Specify a derived class Program#1: Write two classes Move and Move2. Move class has attribute of position which is initialized to zero when an object is created. It also has a member functions forward() which increments the value of position by 1 and show() function to display the value of position.Move2 class is a derived class and has a member function backward() to decrement the value of position by 1.
  • 29.  AccessingConstructor of parent Class: Program#1: Write a program in which derived class access the constructor of parent class.
  • 30.  Derived Class Constructor: Program#1: Write a program that explains the concepts of execution of constructor in single inheritance.
  • 31. Program#2: Write a program that explains the concepts of derived class constructor in inheritance.
  • 32.  Function Overriding: Program 1: Write a program that explains concept of function overriding in inheritance.
  • 33.
  • 34. Program#2: Write a program that explains concept of function overriding.
  • 35.
  • 36.  TYPES OF INHERITANCE:  Public Inheritance: Program#1: Write a program that declares two classes and defines a relationship between them using public inheritance.
  • 37.  Protected Inheritance: Program#1: Write a program that declares two classes and defines a relationship between them using protected inheritance.
  • 38.  Private Inheritance: Program#1: Write a program that declares two classes and defines a relationship between them using private inheritance.
  • 39.
  • 40.  Multilevel Inheritance: Program#1: Write a program that demonstrate the use of multilevel inheritance.
  • 41.
  • 42. Program#2: Write a class Person that has the attributes of id, name and address. It has a constructor to initialize, a member function to input and a member function to display data members. Create 2nd class Student that inherits Person class. It has additional attributes of roll number and marks. It also has member function to input and display its data members. Create 3rd class Scholarship that inherits Student class. It has additional attributes of Scholarship name and amount. It also has member function to input and display its data members.
  • 43.
  • 44.  Multilevel Inheritance with Parameters: Program#1:
  • 45.
  • 46.  Multiple Inheritance: Program#1: Write a program that demonstrate the use of multiple inheritance.
  • 47.
  • 48.  Constructor in Multiple Inheritance:  Constructor without Parameters: Program#1: Write a program that demonstrates the use of constructor (without parameter) in multiple inheritance.
  • 49.  Constructor with Parameters: Program#1: Write a program that demonstrates the use of constructor (with parameter) in multiple inheritance.
  • 50.
  • 51.  Removing Ambiguity: Program#1: Write a program that demonstrate ambiguity in multiple inheritance.
  • 52. Program#2: Write a program that removes the ambiguity in multiple inheritance.
  • 53.  Container Ship: Program#1: Write a class Result that has an array of integers as attributes. It has a member function to input and a member function to display average of array elements. Create another class Student that inherits Result class. It has additional attributes of roll number, name and an object of type Result. It has a member function to input and a member function to display its data members.
  • 54.
  • 55. POLYMORPHISM & VIRTUAL FUNCTIONS  Pointer to objects: Program#1: Write a class with an integer data member, a function to input and a function to display it. Create an object of the class using pointer and calls its member functions.
  • 56.  Array of Pointers to Objects: Program#1: Write a class that contains an attribute name, a function to input and a function to display name. Create an array of pointers in which each element refers to an object of the class.
  • 57.  Pointers and Inheritance: Program#1: Write a program that demonstrate the use of pointer and inheritance.
  • 58.  Virtual Function: Program#1: Write a program that demonstrate the use of virtual function.
  • 59.  Early Binding: Program#1: Write a program that demonstrate the use of early binding.
  • 60.  Late Binding: Program#1: Write a program that demonstrate the use of late binding(dynamic binding).
  • 61.  Pure Virtual Function :  Abstract Classes: Program#1: Write a program that demonstrate the use of Pure Virtual function.
  • 62.  Virtual Base Class : Program#1: Write a program that demonstrate the use of Virtual Base Class.
  • 63. Program#2: Write a program that demonstrate the use of Virtual Base Class.
  • 64. TEMPLATES  Function Templates : Program#1: Write a program that accepts two numeric values and display the maximum number. Use function template to find the maximum value.
  • 65. Program#2: Write a function template that accepts a value of any type and then display it.
  • 66.  Class Template: Program#1: Write a class template that stores five values of any type in an array.
  • 67. Program#2: Write a function template that accepts a value of any type and then display it.
  • 68. FILE HANDLING  Writing Data to Formatted Files I/O: Program#01: Write a program that writes three characters in a file using formatted I/O.
  • 69. Program#02: Write a program that inputs the names of five cities and store them in a file city.txt.
  • 70.  Detecting End-of-File: Program#01: Write a program that displays all records from city.txt prepared in previous example.
  • 71.  Reading Lines From Files: Program#01: Write a program that stored five lines of strings in a file and then displays them on the screen by reading these lines.
  • 72.  Character I/O:  Writing Single Character: Program#01: Write a program that inputs five characters from the user and stores them in a file