SlideShare a Scribd company logo
Er Kabita Parajuli
Object-Oriented
Programming(OOP)
Lecture 1
1
Course Contents
What Procedural Oriented Programming Language?
What is OOP?
Introduction to OOP
Introduction to C++ programming
Classes and Object
Principles of Object Oriented programming
1. Inheritance
2. polymorphism
3. Encapsulation
4. Data abstraction
Benefits of object oriented Programming
2
What is Procedural
Programming Languages?
• Is standard programming approach,
used by language such as C,Fortran
and Basic.
• Tells computer “what to do?” and
“How to do it ?”
• involves the steps that must be
followed to accomplished a specified
tasks .
Fig: Typical Structure of Procedure Oriented Programs
3
The programming paradigm for procedural programming language is
1. Decide which procedure you want:
2. use the best algorithm you can find.
we can say the procedure programming language focuses on algorithm or procedure
to perform a particular job.
Large programs are divided into smaller programs called functions.
Data move openly around the system from function to functions.
4
int main(){
int a;
int b;
printf(“enter first value n”);
scanf(“%d”,&a);
printf(“enter second value n”);
scanf(%d”, &b);
………
}
5
• Step by Step entry of list of
instruction.
And this approach was called Structural
or procedural programming
languages where instructions was
passed in certain procedure.
Growing Complexity and size code
there need somthing more
convenient and there start OOP.
What is Object-Oriented Programming?
The OOP programming approach is based on fundamental concepts of class and
object.
OOP allows decomposition of a problem into a number of entities called objects and
then builds data and functions around these objects.
There are many object-oriented programming languages including JavaScript, C++,
Java, and Python.
6
Introduction to OOP
It is programming style which is associated with concepts of class and object
and various other concepts like:
1. Inheritance
2. polymorphism
3. abstraction
4. Encapsulation etc
Program are divided into small modules known as classes.
Function and data are tied together in an object.
7
8
Introduction to C++
• C++ is a general purpose programming language that was developed as the
enhancement of the C language t include object-oriented paradigm. The basics
syntax and code structure of both C and C++ are the same.
• C++ was developed by Bjarne Stroustrup at bell lab in 1979 and commonly called as
“C with Classes”
• It is simple language that program can be divided down into logical units and parts
has rid library support and variety of data types.
• C++ supports the four primary features of OOP : encapsulation, polymorphism,
abstraction, and inheritance.
• A function is a minimum requirement for a C++ program to run.
9
• the program to display message “welcome to c++!!” in screen using c++ can be
written as :
#include <iostream.h>
void main()
{
cout<<“welcome to c++!!”;
}
10
Classes
A class represent the group of objects that share common properties, behavior and
relationships.
It is an abstract blueprint used to create more specific, concrete objects.
For examples: The name ‘Computer’ can be class that represent personal
computer, lab computer and computer with similar characteristics.
Thus a class is an identifier which is general name i.e family/group name defined to
represent object of similar characteristics.
11
What does a class define
ATTRIBUTES
• name
• height
• weight
• gender
• age
BEHAVIOUR
• Walk
• run
• jump
• speak
• sleep
• Attributes are characteristics described by the class
and behavior describe what a class can do.
• For example If we are describing the class person
then its attributes are name height weight then its
behavior is walk run jump and so on.
• Attributes and Behavior in most of case are describes
as properties and methods .
• Class is describing them in a abstract i.e if class say a
person has a name and has height but does not say
what a name is because a class is description of
something
PROPERTIES
• name
• height
• weight
• gender
• age
METHODS
• Walk
• run
• jump
• speak
• sleep
12
• A class definition starts with keywords class followed by class name; and class body , enclosed by a pair of curly braces. It
must be followed by semicolon at the end.
class class_name
{
private:
variable declaration;
function declaration;
public:
variable declaration;
function declaration;
protected:
variable declaration;
function declaration;
};
Declaration of class
13
Objects
• An object is a real world entity with some characteristics and behavior. The world is
full of object such as pen, lamp, house, car, dog, cat and so on.
• Each object has unique identity and a states.The states of an object is define by
member variables.The object behaviors is defined by its member methods.
• It is an instances of classes .Creating the object is like defining a variable of a data
type.
• Once the class has been declared, we can create variables of that type by using the
class name.
• An object does not exits until the class has been created ; the class is just definition.
14
when a object is physically created, space for that object is allocated in primary
memory. It is possible to have multiple object of the class.
syntax of creating object:
class_name object_name;
e.g.
Box b1; // assume box as a box name
the statement Box b1; creates a variable b1 of type Box.The variable b1 is known as
object of the class Box. Thus, class variables are known was object.
We can create multiple object of the class as follows:
Box b1, b2, b3 ;
Syntax of creating the object
15
Principles of Object Oriented Programming
• The OOP programming is based on the four major fundamental principles.The OOP
principles includes:
1. Encapsulation
2. Inheritance
3. Abstraction
4. Polymorphism
16
Principles of OOP
17
1. Inheritance
• The inheritance is the process of acquiring the existing functionality odf the parent
class and adding additional features and functionality in to zither inherited child class.
• It is the process of deriving one class from another class. The existing class is known
as base class, super class or parent class and the newly created class is known as
derived class, child class and sub class.
• The derived class inherits all the features, expect private members inherent in the
base class.Inheritance supports the properties of code resuability and reliability
18
For examples
We can create base class named FRUIT and
define derived class as MANGO, ORANGE,
BANANA etc.
Each of them have common characteristics
like taste, price and season. The common
characteristic are in Base class. Each of the
characteristics are in derived class with
additional features or attributes.
MANGO would have its own defined feature,
ORANGE would have its own features and
BANANA would have its owns feature and so
on .
Figure:Child classes of the classes
Single Inheritance
Types of Inheritance
Multilevel
Inheritance
Hybrid
Inheritance
Multiple
Inheritance
20
2. Polymorphism
• The word poly means many and morphe means forms.
• Polymorphism means the ability to take more than one form.
• The function overloading, operator overloading, function overriding, virtual function
are the examples of polymorphism.
• In function overloading two or more functions have same name but with different
parameters are used.
• In function overriding, two or more function, with same name and same parameter but
one defined in base class and other in child class are used.
21
22
• The polymorphism can be defined
ass singe object as single object
with multiple behavior.
• the common use of polymorphism in
OOP occurs when a parent class
reference is used to refer to a child
class object.
• the common and simple use of
polymorphism in OOP program is
the use of same method name.
• For example, define many method
with same method name but
different implementation.
The process of binding the data and
methods together as a single unit is
referred as encapsulation.
It prevents the data from
unauthorized use from other parts of
program.
23
3. Encapsulation
• Mechanism to hide the member of the class and providing the access to only some of
them.
• We can make member of class private , public and protected. The outside world
cannot access those member which have been made private and the public member
can be accessed from the class as well was from outside the class.
• In this way class can hide some member from outside the world and provide the
security to them.
Data Hiding
24
4. Data Abstraction
• Abstraction refers as an act of representing essential features with out including
background details or explanation.
• It is methodology that supports use of compound or complex object without its detail
knowledge
• simply it refers to hiding the complexity.
• For examples
• A Class car is made up of an engine, gearbox, steering object and many more
components of the car work internally but only how the interface with them i.e
message to them ,receiving message from them
25
Benefits of Object Oriented languages
Better code reusability using object and inheritance.
Principles of data hiding helps build secure system.
Multiple objects can coexist without any interference.
Software complexity can be easily managed.
26
27
Thank You

More Related Content

PPTX
Inheritance in java
PDF
Memory Management C++ (Peeling operator new() and delete())
PDF
كتاب تعلم الاكسل من الصفر حتى الإحتراف.pdf
PPTX
Object Oriented Programming ppt presentation
PDF
Object-oriented Programming-with C#
PPTX
انواع صفحات الويب
PPTX
Concurrency control
Inheritance in java
Memory Management C++ (Peeling operator new() and delete())
كتاب تعلم الاكسل من الصفر حتى الإحتراف.pdf
Object Oriented Programming ppt presentation
Object-oriented Programming-with C#
انواع صفحات الويب
Concurrency control

What's hot (20)

PPT
Object Oriented Programming Concepts
PPTX
Type casting
PPT
9. Input Output in java
PDF
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
PPTX
Oops concept in c++ unit 3 -topic 4
PPTX
Operators in java
PPTX
Static Members-Java.pptx
PPTX
Method overloading
PPT
Abstract class
PPT
Data abstraction and object orientation
PPTX
Introduction to oop
PPT
Exception Handling in JAVA
PPTX
Static Data Members and Member Functions
PPTX
Method Overloading in Java
PPT
PHP - Introduction to PHP Forms
PPT
Javascript
PPTX
Inner classes in java
PPT
Java collections concept
PPTX
Constructor in java
Object Oriented Programming Concepts
Type casting
9. Input Output in java
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
Oops concept in c++ unit 3 -topic 4
Operators in java
Static Members-Java.pptx
Method overloading
Abstract class
Data abstraction and object orientation
Introduction to oop
Exception Handling in JAVA
Static Data Members and Member Functions
Method Overloading in Java
PHP - Introduction to PHP Forms
Javascript
Inner classes in java
Java collections concept
Constructor in java
Ad

Similar to oop.pptx (20)

PPT
Java Fundamentalojhgghjjjjhhgghhjjjjhhj.ppt
PPTX
Class and Objects in python programming.pptx
PPTX
Introduction to oop and java fundamentals
PDF
Unit 3-Classes ,Objects and Inheritance.pdf
PPTX
Principles of OOPs.pptx
PPTX
Principles and advantages of oop ppt
PPTX
c++session 1.pptx
PPTX
c++.pptxwjwjsijsnsksomammaoansnksooskskk
PPT
Oops and c fundamentals
PPTX
Summer Training Project On C++
PPTX
Object Oriented Programming (OOP) Introduction
PPTX
Introduction to OOP concepts
PPTX
Oop ppt
PPTX
Need of object oriented programming
PDF
M.c.a (sem iii) paper - i - object oriented programming
PPTX
java oops and java very important for .pptx
PPTX
java oops compilation object class inheritance.pptx
PPTX
Untitled presentation about object oriented.pptx
PPTX
Object Oriented Programming WEOBRDSLKBNSDF
PPTX
introduction of Object oriented programming
Java Fundamentalojhgghjjjjhhgghhjjjjhhj.ppt
Class and Objects in python programming.pptx
Introduction to oop and java fundamentals
Unit 3-Classes ,Objects and Inheritance.pdf
Principles of OOPs.pptx
Principles and advantages of oop ppt
c++session 1.pptx
c++.pptxwjwjsijsnsksomammaoansnksooskskk
Oops and c fundamentals
Summer Training Project On C++
Object Oriented Programming (OOP) Introduction
Introduction to OOP concepts
Oop ppt
Need of object oriented programming
M.c.a (sem iii) paper - i - object oriented programming
java oops and java very important for .pptx
java oops compilation object class inheritance.pptx
Untitled presentation about object oriented.pptx
Object Oriented Programming WEOBRDSLKBNSDF
introduction of Object oriented programming
Ad

Recently uploaded (20)

PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
PPTX
Strings in CPP - Strings in C++ are sequences of characters used to store and...
PDF
composite construction of structures.pdf
PPT
Mechanical Engineering MATERIALS Selection
PPTX
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PPTX
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
PDF
Structs to JSON How Go Powers REST APIs.pdf
PPT
Project quality management in manufacturing
PPTX
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
PPTX
Lecture Notes Electrical Wiring System Components
PDF
PPT on Performance Review to get promotions
PPTX
CH1 Production IntroductoryConcepts.pptx
PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PPTX
Lesson 3_Tessellation.pptx finite Mathematics
PDF
Operating System & Kernel Study Guide-1 - converted.pdf
DOCX
573137875-Attendance-Management-System-original
PPTX
Sustainable Sites - Green Building Construction
PPTX
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
PDF
Model Code of Practice - Construction Work - 21102022 .pdf
PDF
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
Strings in CPP - Strings in C++ are sequences of characters used to store and...
composite construction of structures.pdf
Mechanical Engineering MATERIALS Selection
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
Structs to JSON How Go Powers REST APIs.pdf
Project quality management in manufacturing
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
Lecture Notes Electrical Wiring System Components
PPT on Performance Review to get promotions
CH1 Production IntroductoryConcepts.pptx
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
Lesson 3_Tessellation.pptx finite Mathematics
Operating System & Kernel Study Guide-1 - converted.pdf
573137875-Attendance-Management-System-original
Sustainable Sites - Green Building Construction
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
Model Code of Practice - Construction Work - 21102022 .pdf
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...

oop.pptx

  • 2. Course Contents What Procedural Oriented Programming Language? What is OOP? Introduction to OOP Introduction to C++ programming Classes and Object Principles of Object Oriented programming 1. Inheritance 2. polymorphism 3. Encapsulation 4. Data abstraction Benefits of object oriented Programming 2
  • 3. What is Procedural Programming Languages? • Is standard programming approach, used by language such as C,Fortran and Basic. • Tells computer “what to do?” and “How to do it ?” • involves the steps that must be followed to accomplished a specified tasks . Fig: Typical Structure of Procedure Oriented Programs 3
  • 4. The programming paradigm for procedural programming language is 1. Decide which procedure you want: 2. use the best algorithm you can find. we can say the procedure programming language focuses on algorithm or procedure to perform a particular job. Large programs are divided into smaller programs called functions. Data move openly around the system from function to functions. 4
  • 5. int main(){ int a; int b; printf(“enter first value n”); scanf(“%d”,&a); printf(“enter second value n”); scanf(%d”, &b); ……… } 5 • Step by Step entry of list of instruction. And this approach was called Structural or procedural programming languages where instructions was passed in certain procedure. Growing Complexity and size code there need somthing more convenient and there start OOP.
  • 6. What is Object-Oriented Programming? The OOP programming approach is based on fundamental concepts of class and object. OOP allows decomposition of a problem into a number of entities called objects and then builds data and functions around these objects. There are many object-oriented programming languages including JavaScript, C++, Java, and Python. 6
  • 7. Introduction to OOP It is programming style which is associated with concepts of class and object and various other concepts like: 1. Inheritance 2. polymorphism 3. abstraction 4. Encapsulation etc Program are divided into small modules known as classes. Function and data are tied together in an object. 7
  • 8. 8
  • 9. Introduction to C++ • C++ is a general purpose programming language that was developed as the enhancement of the C language t include object-oriented paradigm. The basics syntax and code structure of both C and C++ are the same. • C++ was developed by Bjarne Stroustrup at bell lab in 1979 and commonly called as “C with Classes” • It is simple language that program can be divided down into logical units and parts has rid library support and variety of data types. • C++ supports the four primary features of OOP : encapsulation, polymorphism, abstraction, and inheritance. • A function is a minimum requirement for a C++ program to run. 9
  • 10. • the program to display message “welcome to c++!!” in screen using c++ can be written as : #include <iostream.h> void main() { cout<<“welcome to c++!!”; } 10
  • 11. Classes A class represent the group of objects that share common properties, behavior and relationships. It is an abstract blueprint used to create more specific, concrete objects. For examples: The name ‘Computer’ can be class that represent personal computer, lab computer and computer with similar characteristics. Thus a class is an identifier which is general name i.e family/group name defined to represent object of similar characteristics. 11
  • 12. What does a class define ATTRIBUTES • name • height • weight • gender • age BEHAVIOUR • Walk • run • jump • speak • sleep • Attributes are characteristics described by the class and behavior describe what a class can do. • For example If we are describing the class person then its attributes are name height weight then its behavior is walk run jump and so on. • Attributes and Behavior in most of case are describes as properties and methods . • Class is describing them in a abstract i.e if class say a person has a name and has height but does not say what a name is because a class is description of something PROPERTIES • name • height • weight • gender • age METHODS • Walk • run • jump • speak • sleep 12
  • 13. • A class definition starts with keywords class followed by class name; and class body , enclosed by a pair of curly braces. It must be followed by semicolon at the end. class class_name { private: variable declaration; function declaration; public: variable declaration; function declaration; protected: variable declaration; function declaration; }; Declaration of class 13
  • 14. Objects • An object is a real world entity with some characteristics and behavior. The world is full of object such as pen, lamp, house, car, dog, cat and so on. • Each object has unique identity and a states.The states of an object is define by member variables.The object behaviors is defined by its member methods. • It is an instances of classes .Creating the object is like defining a variable of a data type. • Once the class has been declared, we can create variables of that type by using the class name. • An object does not exits until the class has been created ; the class is just definition. 14
  • 15. when a object is physically created, space for that object is allocated in primary memory. It is possible to have multiple object of the class. syntax of creating object: class_name object_name; e.g. Box b1; // assume box as a box name the statement Box b1; creates a variable b1 of type Box.The variable b1 is known as object of the class Box. Thus, class variables are known was object. We can create multiple object of the class as follows: Box b1, b2, b3 ; Syntax of creating the object 15
  • 16. Principles of Object Oriented Programming • The OOP programming is based on the four major fundamental principles.The OOP principles includes: 1. Encapsulation 2. Inheritance 3. Abstraction 4. Polymorphism 16
  • 18. 1. Inheritance • The inheritance is the process of acquiring the existing functionality odf the parent class and adding additional features and functionality in to zither inherited child class. • It is the process of deriving one class from another class. The existing class is known as base class, super class or parent class and the newly created class is known as derived class, child class and sub class. • The derived class inherits all the features, expect private members inherent in the base class.Inheritance supports the properties of code resuability and reliability 18
  • 19. For examples We can create base class named FRUIT and define derived class as MANGO, ORANGE, BANANA etc. Each of them have common characteristics like taste, price and season. The common characteristic are in Base class. Each of the characteristics are in derived class with additional features or attributes. MANGO would have its own defined feature, ORANGE would have its own features and BANANA would have its owns feature and so on . Figure:Child classes of the classes
  • 20. Single Inheritance Types of Inheritance Multilevel Inheritance Hybrid Inheritance Multiple Inheritance 20
  • 21. 2. Polymorphism • The word poly means many and morphe means forms. • Polymorphism means the ability to take more than one form. • The function overloading, operator overloading, function overriding, virtual function are the examples of polymorphism. • In function overloading two or more functions have same name but with different parameters are used. • In function overriding, two or more function, with same name and same parameter but one defined in base class and other in child class are used. 21
  • 22. 22 • The polymorphism can be defined ass singe object as single object with multiple behavior. • the common use of polymorphism in OOP occurs when a parent class reference is used to refer to a child class object. • the common and simple use of polymorphism in OOP program is the use of same method name. • For example, define many method with same method name but different implementation.
  • 23. The process of binding the data and methods together as a single unit is referred as encapsulation. It prevents the data from unauthorized use from other parts of program. 23 3. Encapsulation
  • 24. • Mechanism to hide the member of the class and providing the access to only some of them. • We can make member of class private , public and protected. The outside world cannot access those member which have been made private and the public member can be accessed from the class as well was from outside the class. • In this way class can hide some member from outside the world and provide the security to them. Data Hiding 24
  • 25. 4. Data Abstraction • Abstraction refers as an act of representing essential features with out including background details or explanation. • It is methodology that supports use of compound or complex object without its detail knowledge • simply it refers to hiding the complexity. • For examples • A Class car is made up of an engine, gearbox, steering object and many more components of the car work internally but only how the interface with them i.e message to them ,receiving message from them 25
  • 26. Benefits of Object Oriented languages Better code reusability using object and inheritance. Principles of data hiding helps build secure system. Multiple objects can coexist without any interference. Software complexity can be easily managed. 26