SlideShare a Scribd company logo
1 of 27
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

What's hot

What's hot (20)

Introduction to Object Oriented Programming
Introduction to Object Oriented ProgrammingIntroduction to Object Oriented Programming
Introduction to Object Oriented Programming
 
RAID LEVELS
RAID LEVELSRAID LEVELS
RAID LEVELS
 
QSpiders - Unix Operating Systems and Commands
QSpiders - Unix Operating Systems  and CommandsQSpiders - Unix Operating Systems  and Commands
QSpiders - Unix Operating Systems and Commands
 
Oop Presentation
Oop PresentationOop Presentation
Oop Presentation
 
operating system structure
operating system structureoperating system structure
operating system structure
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
 
Cocomo model
Cocomo modelCocomo model
Cocomo model
 
Cohesion and coupling
Cohesion and couplingCohesion and coupling
Cohesion and coupling
 
Principles and advantages of oop ppt
Principles and advantages of oop pptPrinciples and advantages of oop ppt
Principles and advantages of oop ppt
 
Files in c++ ppt
Files in c++ pptFiles in c++ ppt
Files in c++ ppt
 
Basic concept of OOP's
Basic concept of OOP'sBasic concept of OOP's
Basic concept of OOP's
 
Deadlock Avoidance - OS
Deadlock Avoidance - OSDeadlock Avoidance - OS
Deadlock Avoidance - OS
 
Inter Process Communication
Inter Process CommunicationInter Process Communication
Inter Process Communication
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in java
 
Virtual memory - Demand Paging
Virtual memory - Demand PagingVirtual memory - Demand Paging
Virtual memory - Demand Paging
 
1 introduction of OOAD
1 introduction of OOAD1 introduction of OOAD
1 introduction of OOAD
 
Encapsulation C++
Encapsulation C++Encapsulation C++
Encapsulation C++
 
OOPS Basics With Example
OOPS Basics With ExampleOOPS Basics With Example
OOPS Basics With Example
 
java interface and packages
java interface and packagesjava interface and packages
java interface and packages
 
Need of object oriented programming
Need of object oriented programmingNeed of object oriented programming
Need of object oriented programming
 

Similar to oop.pptx

Introduction to oop
Introduction to oopIntroduction to oop
Introduction to oopcolleges
 
Introduction to oop and java fundamentals
Introduction to oop and java fundamentalsIntroduction to oop and java fundamentals
Introduction to oop and java fundamentalsAnsgarMary
 
c++session 1.pptx
c++session 1.pptxc++session 1.pptx
c++session 1.pptxPadmaN24
 
Oops and c fundamentals
Oops and c fundamentals Oops and c fundamentals
Oops and c fundamentals umesh patil
 
Summer Training Project On C++
Summer Training Project On  C++Summer Training Project On  C++
Summer Training Project On C++KAUSHAL KUMAR JHA
 
Object Oriented Programming (OOP) Introduction
Object Oriented Programming (OOP) IntroductionObject Oriented Programming (OOP) Introduction
Object Oriented Programming (OOP) IntroductionSamuelAnsong6
 
Introduction to OOP concepts
Introduction to OOP conceptsIntroduction to OOP concepts
Introduction to OOP conceptsAhmed Farag
 
introduction of Object oriented programming
introduction of Object oriented programmingintroduction of Object oriented programming
introduction of Object oriented programmingRiturajJain8
 
SE-IT JAVA LAB OOP CONCEPT
SE-IT JAVA LAB OOP CONCEPTSE-IT JAVA LAB OOP CONCEPT
SE-IT JAVA LAB OOP CONCEPTnikshaikh786
 
CPP-Unit 1.pptx
CPP-Unit 1.pptxCPP-Unit 1.pptx
CPP-Unit 1.pptxYashKoli22
 
Object Oriented Programming
Object Oriented ProgrammingObject Oriented Programming
Object Oriented Programmingsharmisivarajah
 
U1 JAVA.pptx
U1 JAVA.pptxU1 JAVA.pptx
U1 JAVA.pptxmadan r
 
SKILLWISE - OOPS CONCEPT
SKILLWISE - OOPS CONCEPTSKILLWISE - OOPS CONCEPT
SKILLWISE - OOPS CONCEPTSkillwise Group
 

Similar to oop.pptx (20)

Introduction to oop
Introduction to oopIntroduction to oop
Introduction to oop
 
Introduction to oop and java fundamentals
Introduction to oop and java fundamentalsIntroduction to oop and java fundamentals
Introduction to oop and java fundamentals
 
Principles of OOPs.pptx
Principles of OOPs.pptxPrinciples of OOPs.pptx
Principles of OOPs.pptx
 
c++session 1.pptx
c++session 1.pptxc++session 1.pptx
c++session 1.pptx
 
Oops and c fundamentals
Oops and c fundamentals Oops and c fundamentals
Oops and c fundamentals
 
Summer Training Project On C++
Summer Training Project On  C++Summer Training Project On  C++
Summer Training Project On C++
 
Object Oriented Programming (OOP) Introduction
Object Oriented Programming (OOP) IntroductionObject Oriented Programming (OOP) Introduction
Object Oriented Programming (OOP) Introduction
 
Introduction to OOP concepts
Introduction to OOP conceptsIntroduction to OOP concepts
Introduction to OOP concepts
 
Oop ppt
Oop pptOop ppt
Oop ppt
 
M.c.a (sem iii) paper - i - object oriented programming
M.c.a (sem   iii) paper - i - object oriented programmingM.c.a (sem   iii) paper - i - object oriented programming
M.c.a (sem iii) paper - i - object oriented programming
 
introduction of Object oriented programming
introduction of Object oriented programmingintroduction of Object oriented programming
introduction of Object oriented programming
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
 
SE-IT JAVA LAB OOP CONCEPT
SE-IT JAVA LAB OOP CONCEPTSE-IT JAVA LAB OOP CONCEPT
SE-IT JAVA LAB OOP CONCEPT
 
Java_notes.ppt
Java_notes.pptJava_notes.ppt
Java_notes.ppt
 
CPP-Unit 1.pptx
CPP-Unit 1.pptxCPP-Unit 1.pptx
CPP-Unit 1.pptx
 
Object Oriented Programming
Object Oriented ProgrammingObject Oriented Programming
Object Oriented Programming
 
130704798265658191
130704798265658191130704798265658191
130704798265658191
 
U1 JAVA.pptx
U1 JAVA.pptxU1 JAVA.pptx
U1 JAVA.pptx
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
 
SKILLWISE - OOPS CONCEPT
SKILLWISE - OOPS CONCEPTSKILLWISE - OOPS CONCEPT
SKILLWISE - OOPS CONCEPT
 

Recently uploaded

Introduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxIntroduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxvipinkmenon1
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLDeelipZope
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx959SahilShah
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...VICTOR MAESTRE RAMIREZ
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfAsst.prof M.Gokilavani
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerAnamika Sarkar
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learningmisbanausheenparvam
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 

Recently uploaded (20)

Introduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxIntroduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptx
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCL
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learning
 
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 

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