SlideShare a Scribd company logo
1 of 37
FOUR PILLERS
OF OOPS
Shwetark
Deshpande
(44)
Group Members
02
Omkar
Gadge
(52)
Ajinkya
Gunjkar
(63)
Devesh
Gugale
(62)
Preshit
Ghode
(59)
1. Introduction
2. Encapsulation
3. Abstraction
4. Inheritance
5. Polymorphism
6.Conclusion
3
Content
1.
INTRODUCTION
What is OOPS?
OBJECT
ORIENTED
PROGRAMMIN
G
 Object Oriented programming (OOP) is a
programming paradigm that relies on the
concept of classes and objects.
 It is used to structure a software program
into simple, reusable pieces of code
blueprints, which are used to create
individual instances of objects.
 There are many object-oriented
programming languages including
JavaScript, C++, Java, and Python.
5
Why do we need
OOP?
• Object-oriented programming aims to
implement real-world entities like
inheritance, hiding, polymorphism etc in
programming.
• The main aim of OOP is to bind together
the data and the functions that operate on
them so that no other part of the code can
access this data except that function.
6
2.
Encapsulation
“The ultimate aim of encapsulation is to hide
‘sensitive’ data from user.”
8
Definition
• Encapsulation is a process of binding or
wrapping the data and the codes that
operates on the data into a single entity.
This keeps the data safe from outside
interface and misuse. One way to think
about encapsulation is as a protective
wrapper that prevents code and data
from being arbitrarily accessed by other
code defined outside the wrapper.
9
How
Encapsulation
is achieved ?
• Access Modifiers :-
○ Public
○ Private
○ Protected
10
How
Encapsulation
is achieved in a
class ?
• Make all the data members private.
• Create public setter and getter functions
for each data member in such a way that
the set function set the value of data
member and get function get the value of
data member.
11
12
13
Advantage of Encapsulation in C++
• The main advantage of using of encapsulation is to secure the data
from other methods, when we make a data private then these data
only use within the class, but these data not accessible outside the
class.
• The major benefit of data encapsulation is the security of the data.
It protects the data from unauthorized users that we inferred from
the above stated real-real problem.
• Encapsulation is also useful in hiding the data(instance variables)
of a class from an illegal direct access.
Dis-Advantage of Encapsulation in C++
○ You can't access private data outside the class ..
14
3.
Abstraction
Abstraction
• Using simple things to represent
complexity
• Hide complex details from user
• Abstraction is using simple
classes to represent complexity.
Abstraction is an extension of
encapsulation. For example, you don’t
have to know all the details of how the
engine works to drive a car.
16
• Lets consider this example for
understanding Abstraction
17
Abstraction
• A driver only uses a small selection of tools: like
gas pedal, brake, steering wheel, blinker. The
engineering is hidden from the driver. To make a
car work, a lot of pieces have to work under the
hood, but exposing that information to the driver
would be a dangerous distraction.
• Abstraction also serves an important security
role. By only displaying selected pieces of data,
and only allowing data to be accessed
through classes and modified through methods,
we protect the data from exposure. To continue
with the car example, you wouldn’t want an open
gas tank while driving a car.
18
• Simple, high level user interfaces
• Complex code is hidden
• Security
• Easier software maintenance
• Code updates rarely change abstraction
19
The benefits
of
abstraction
are
summarized
below
4.
Inheritance
What is
Inheritance?
○ Inheritance is a mechanism in which one class acquires the
property of another class.
○ Reusability is an important concept of OOPs.
○ Boost the Maintainablity of the code.
○ The class from which the new class inherits properties is called
BASE CLASS and the new created class is called DERIVED
CLASS.
○ Syntax - class derived-class: access-specifier base-class
{
// data members and member functions of derived class
}
22
23
Types of Inheritance
Single Inheritance Multiple Inheritance Multilevel Inheritance
24
Hierarchical Inheritance Hybrid Inheritance
25
5.
Polymorphism
Definition
○ Polymorphism means "the condition of
occurring in several different forms."
That's exactly what the fourth and final
pillar is concerned with – types in the
same inheritance chains being able to do
different things.
○ The word polymorphism means having many
forms. In simple words, we can define
polymorphism as the ability of a message to
be displayed in more than one form.
○ Polymorphism is considered as one of the
important features of Object Oriented
Programming.
27
In C++
polymorphism
is mainly
divided into two
types
Compile time
polymorphism:
This type of polymorphism
is achieved by function
overloading or operator
overloading.
Function
Overloading:
Function overloading is
a feature in C++ where
two or more functions
can have the same
name but different
parameters.
28
#include<iostream>
#include<stdio.h>
int area(int, int);
float area(int);
int main()
{
int r;
std::cout<<"Enter radius of a
circle";
std::cin>>r;
float A=area(r);
std::cout<<"Area of Circle is
"<<A;
29
int l,b,a;
std::cout<<"Enter length and
breadth of rectangle";
std::cin>>l>>b;
a=area(l,b);
std::cout<<"area of Rectangle
is"<<a;
}
float area(int R)
{
return(3.14*R*R);
}
int area(int L,int B)
{
return(L*B);
}
Operator
Overloading
• In C++, we can make operators to work
for user defined classes. This means C++
has the ability to provide the operators
with a special meaning for a data type,
this ability is known as operator
overloading.
• For example, we can overload an
operator ‘+’ in a class like String so that
we can concatenate two strings by just
using
30
#include<iostream>
class Complex
{
private:
int a,b;
public:
void setData(int x, int y)
{
a=x;
b=y;
}
void showData()
Complex operator +(Complex c)
31
{
std::cout<<"na="<<a<<"nb="<<b;
}
{ Complex temp;
temp.a=a+c.a;
temp.b=b+c.b;
return(temp); }
};
int main()
{ Complex c1,c2,c3;
c1.setData(3,4);
c2.setData(5,6);
c3=c1+c2;
c3.showData();
}
Runtime
polymorphism
○ This type of polymorphism is achieved
by Function Overriding.
○ A virtual function is a member function
which is declared in the base class using
the keyword virtual and is re-defined
(Overriden) by the derived class.
32
#include <iostream>
using namespace std;
// Base class
class Shape
{
public:
Shape(int l, int w)
{
length = l;
width = w;
} // default constructor
int get_Area()
{
33
cout << "This is call to
parent class area" << endl;
}
protected:
int length, width;
};
// Derived class
class Square : public Shape
{
public:
Square(int l = 0, int w = 0)
: Shape(l, w)
{
} // declaring and initializing derived
class
// constructor
int get_Area()
{ cout << "Square area:
" << length * width << endl;
return (length * width);
}
};
// Derived class
class Rectangle : public Shape
{ public:
Rectangle(int l = 0, int w
= 0)
: Shape(l, w)
{
} // declaring and initializing derived
class
34
// constructor
int get_Area()
{
cout << "Rectangle area: " <<
length * width<< endl;
return (length * width);
}
};
int main(void)
{ Shape* s;
Square sq(5, 5); // making object
of child class Sqaure
Rectangle rec(4, 5); // making
object of child class Rectangle
s = &sq;
s->get_Area();
s = &rec;
s->get_Area();
return 0;
}
CONCLUSION
 Object-Oriented Programming has
many advantages to Procedural
Programming.
 In OOP, data can be made private to a
class such that only member functions
of the class can access the data.
 The objects are processed by their
member data and functions.
35
1. https://www.linkedin.com/pulse/4-pillars-object-oriented-programming-pushkar-kumar
2. https://info.keylimeinteractive.com/the-four-pillars-of-object-oriented-programming
3. https://www.tutorialspoint.com/cplusplus/cpp_polymorphism.htm
4. https://www.guru99.com/java-class-inheritance.html#6
5. https://www.javatpoint.com/cpp-polymorphism
6. https://www.geeksforgeeks.org/encapsulation-in-c/
7. https://www.youtube.com/watch?v=a8ZB-TPB6EU
36
RESOURCES
Thanks!
37

More Related Content

What's hot

Design Patterns: From STUPID to SOLID code
Design Patterns: From STUPID to SOLID codeDesign Patterns: From STUPID to SOLID code
Design Patterns: From STUPID to SOLID codePaulo Gandra de Sousa
 
Oops concepts || Object Oriented Programming Concepts in Java
Oops concepts || Object Oriented Programming Concepts in JavaOops concepts || Object Oriented Programming Concepts in Java
Oops concepts || Object Oriented Programming Concepts in JavaMadishetty Prathibha
 
Class, object and inheritance in python
Class, object and inheritance in pythonClass, object and inheritance in python
Class, object and inheritance in pythonSantosh Verma
 
Inheritance in c++
Inheritance in c++Inheritance in c++
Inheritance in c++Vineeta Garg
 
the Concept of Object-Oriented Programming
the Concept of Object-Oriented Programmingthe Concept of Object-Oriented Programming
the Concept of Object-Oriented ProgrammingAida Ramlan II
 
SOLID Design Principles
SOLID Design PrinciplesSOLID Design Principles
SOLID Design PrinciplesAndreas Enbohm
 
OOP Introduction with java programming language
OOP Introduction with java programming languageOOP Introduction with java programming language
OOP Introduction with java programming languageMd.Al-imran Roton
 
Learn C# Programming - Encapsulation & Methods
Learn C# Programming - Encapsulation & MethodsLearn C# Programming - Encapsulation & Methods
Learn C# Programming - Encapsulation & MethodsEng Teong Cheah
 
Inheritance in c++
Inheritance in c++Inheritance in c++
Inheritance in c++Paumil Patel
 
MySql Triggers Tutorial - The Webs Academy
MySql Triggers Tutorial - The Webs AcademyMySql Triggers Tutorial - The Webs Academy
MySql Triggers Tutorial - The Webs Academythewebsacademy
 
Basic Concepts of OOPs (Object Oriented Programming in Java)
Basic Concepts of OOPs (Object Oriented Programming in Java)Basic Concepts of OOPs (Object Oriented Programming in Java)
Basic Concepts of OOPs (Object Oriented Programming in Java)Michelle Anne Meralpis
 
7 rules of simple and maintainable code
7 rules of simple and maintainable code7 rules of simple and maintainable code
7 rules of simple and maintainable codeGeshan Manandhar
 
Polymorphism In Java
Polymorphism In JavaPolymorphism In Java
Polymorphism In JavaSpotle.ai
 
pl/sql Procedure
pl/sql Procedurepl/sql Procedure
pl/sql ProcedurePooja Dixit
 

What's hot (20)

Design Patterns: From STUPID to SOLID code
Design Patterns: From STUPID to SOLID codeDesign Patterns: From STUPID to SOLID code
Design Patterns: From STUPID to SOLID code
 
Oops concepts || Object Oriented Programming Concepts in Java
Oops concepts || Object Oriented Programming Concepts in JavaOops concepts || Object Oriented Programming Concepts in Java
Oops concepts || Object Oriented Programming Concepts in Java
 
Class, object and inheritance in python
Class, object and inheritance in pythonClass, object and inheritance in python
Class, object and inheritance in python
 
Jdbc ppt
Jdbc pptJdbc ppt
Jdbc ppt
 
Inheritance in c++
Inheritance in c++Inheritance in c++
Inheritance in c++
 
OOP java
OOP javaOOP java
OOP java
 
the Concept of Object-Oriented Programming
the Concept of Object-Oriented Programmingthe Concept of Object-Oriented Programming
the Concept of Object-Oriented Programming
 
SOLID Design Principles
SOLID Design PrinciplesSOLID Design Principles
SOLID Design Principles
 
OOP Introduction with java programming language
OOP Introduction with java programming languageOOP Introduction with java programming language
OOP Introduction with java programming language
 
Learn C# Programming - Encapsulation & Methods
Learn C# Programming - Encapsulation & MethodsLearn C# Programming - Encapsulation & Methods
Learn C# Programming - Encapsulation & Methods
 
Inheritance in c++
Inheritance in c++Inheritance in c++
Inheritance in c++
 
MySql Triggers Tutorial - The Webs Academy
MySql Triggers Tutorial - The Webs AcademyMySql Triggers Tutorial - The Webs Academy
MySql Triggers Tutorial - The Webs Academy
 
Basic Concepts of OOPs (Object Oriented Programming in Java)
Basic Concepts of OOPs (Object Oriented Programming in Java)Basic Concepts of OOPs (Object Oriented Programming in Java)
Basic Concepts of OOPs (Object Oriented Programming in Java)
 
Inheritance C#
Inheritance C#Inheritance C#
Inheritance C#
 
OOP C++
OOP C++OOP C++
OOP C++
 
Polymorphism in oop
Polymorphism in oopPolymorphism in oop
Polymorphism in oop
 
7 rules of simple and maintainable code
7 rules of simple and maintainable code7 rules of simple and maintainable code
7 rules of simple and maintainable code
 
Polymorphism In Java
Polymorphism In JavaPolymorphism In Java
Polymorphism In Java
 
pl/sql Procedure
pl/sql Procedurepl/sql Procedure
pl/sql Procedure
 
Java interfaces
Java interfacesJava interfaces
Java interfaces
 

Similar to Four Pillers Of OOPS

I assignmnt(oops)
I assignmnt(oops)I assignmnt(oops)
I assignmnt(oops)Jay Patel
 
software engineer interview questions.pdf
software engineer interview questions.pdfsoftware engineer interview questions.pdf
software engineer interview questions.pdfRaajpootQueen
 
encapsulation1-150816163959-lva1-app6891.pdf
encapsulation1-150816163959-lva1-app6891.pdfencapsulation1-150816163959-lva1-app6891.pdf
encapsulation1-150816163959-lva1-app6891.pdfkashafishfaq21
 
OOP interview questions & answers.
OOP interview questions & answers.OOP interview questions & answers.
OOP interview questions & answers.Questpond
 
Introduction to oop
Introduction to oopIntroduction to oop
Introduction to oopcolleges
 
OOP lesson1 and Variables.pdf
OOP lesson1 and Variables.pdfOOP lesson1 and Variables.pdf
OOP lesson1 and Variables.pdfHouseMusica
 
EEE oops Vth semester viva questions with answer
EEE oops Vth semester viva questions with answerEEE oops Vth semester viva questions with answer
EEE oops Vth semester viva questions with answerJeba Moses
 
Interoduction to c++
Interoduction to c++Interoduction to c++
Interoduction to c++Amresh Raj
 
Object Oriented Language
Object Oriented LanguageObject Oriented Language
Object Oriented Languagedheva B
 
Data Structure Interview Questions & Answers
Data Structure Interview Questions & AnswersData Structure Interview Questions & Answers
Data Structure Interview Questions & AnswersSatyam Jaiswal
 
Basic Concepts of Object Oriented Programming using C++
Basic Concepts of Object Oriented Programming using C++Basic Concepts of Object Oriented Programming using C++
Basic Concepts of Object Oriented Programming using C++ShivamPathak318367
 

Similar to Four Pillers Of OOPS (20)

Opp concept in c++
Opp concept in c++Opp concept in c++
Opp concept in c++
 
I assignmnt(oops)
I assignmnt(oops)I assignmnt(oops)
I assignmnt(oops)
 
software engineer interview questions.pdf
software engineer interview questions.pdfsoftware engineer interview questions.pdf
software engineer interview questions.pdf
 
Encapsulation C++
Encapsulation C++Encapsulation C++
Encapsulation C++
 
encapsulation1-150816163959-lva1-app6891.pdf
encapsulation1-150816163959-lva1-app6891.pdfencapsulation1-150816163959-lva1-app6891.pdf
encapsulation1-150816163959-lva1-app6891.pdf
 
OOP interview questions & answers.
OOP interview questions & answers.OOP interview questions & answers.
OOP interview questions & answers.
 
Introduction to oop
Introduction to oopIntroduction to oop
Introduction to oop
 
OOP lesson1 and Variables.pdf
OOP lesson1 and Variables.pdfOOP lesson1 and Variables.pdf
OOP lesson1 and Variables.pdf
 
Mca 504 dotnet_unit3
Mca 504 dotnet_unit3Mca 504 dotnet_unit3
Mca 504 dotnet_unit3
 
Php oop (1)
Php oop (1)Php oop (1)
Php oop (1)
 
EEE oops Vth semester viva questions with answer
EEE oops Vth semester viva questions with answerEEE oops Vth semester viva questions with answer
EEE oops Vth semester viva questions with answer
 
Oops
OopsOops
Oops
 
Interoduction to c++
Interoduction to c++Interoduction to c++
Interoduction to c++
 
Ppt of c++ vs c#
Ppt of c++ vs c#Ppt of c++ vs c#
Ppt of c++ vs c#
 
Object Oriented Language
Object Oriented LanguageObject Oriented Language
Object Oriented Language
 
Data Structure Interview Questions & Answers
Data Structure Interview Questions & AnswersData Structure Interview Questions & Answers
Data Structure Interview Questions & Answers
 
Abstraction
Abstraction Abstraction
Abstraction
 
Abstraction
AbstractionAbstraction
Abstraction
 
Question bank unit i
Question bank unit iQuestion bank unit i
Question bank unit i
 
Basic Concepts of Object Oriented Programming using C++
Basic Concepts of Object Oriented Programming using C++Basic Concepts of Object Oriented Programming using C++
Basic Concepts of Object Oriented Programming using C++
 

Recently uploaded

Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.eptoze12
 
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
 
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
 
pipeline in computer architecture design
pipeline in computer architecture  designpipeline in computer architecture  design
pipeline in computer architecture designssuser87fa0c1
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort servicejennyeacort
 
An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...Chandu841456
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxDeepakSakkari2
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfCCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfAsst.prof M.Gokilavani
 
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEINFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEroselinkalist12
 
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
 
Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvLewisJB
 
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)Dr SOUNDIRARAJ N
 
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)dollysharma2066
 
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
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...srsj9000
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptSAURABHKUMAR892774
 
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
 

Recently uploaded (20)

Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.
 
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
 
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...
 
pipeline in computer architecture design
pipeline in computer architecture  designpipeline in computer architecture  design
pipeline in computer architecture design
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
 
An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptx
 
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
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfCCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
 
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEINFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
 
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
 
Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvv
 
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
 
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
 
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
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.ppt
 
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
 
POWER SYSTEMS-1 Complete notes examples
POWER SYSTEMS-1 Complete notes  examplesPOWER SYSTEMS-1 Complete notes  examples
POWER SYSTEMS-1 Complete notes examples
 

Four Pillers Of OOPS

  • 3. 1. Introduction 2. Encapsulation 3. Abstraction 4. Inheritance 5. Polymorphism 6.Conclusion 3 Content
  • 5. OBJECT ORIENTED PROGRAMMIN G  Object Oriented programming (OOP) is a programming paradigm that relies on the concept of classes and objects.  It is used to structure a software program into simple, reusable pieces of code blueprints, which are used to create individual instances of objects.  There are many object-oriented programming languages including JavaScript, C++, Java, and Python. 5
  • 6. Why do we need OOP? • Object-oriented programming aims to implement real-world entities like inheritance, hiding, polymorphism etc in programming. • The main aim of OOP is to bind together the data and the functions that operate on them so that no other part of the code can access this data except that function. 6
  • 8. “The ultimate aim of encapsulation is to hide ‘sensitive’ data from user.” 8
  • 9. Definition • Encapsulation is a process of binding or wrapping the data and the codes that operates on the data into a single entity. This keeps the data safe from outside interface and misuse. One way to think about encapsulation is as a protective wrapper that prevents code and data from being arbitrarily accessed by other code defined outside the wrapper. 9
  • 10. How Encapsulation is achieved ? • Access Modifiers :- ○ Public ○ Private ○ Protected 10
  • 11. How Encapsulation is achieved in a class ? • Make all the data members private. • Create public setter and getter functions for each data member in such a way that the set function set the value of data member and get function get the value of data member. 11
  • 12. 12
  • 13. 13
  • 14. Advantage of Encapsulation in C++ • The main advantage of using of encapsulation is to secure the data from other methods, when we make a data private then these data only use within the class, but these data not accessible outside the class. • The major benefit of data encapsulation is the security of the data. It protects the data from unauthorized users that we inferred from the above stated real-real problem. • Encapsulation is also useful in hiding the data(instance variables) of a class from an illegal direct access. Dis-Advantage of Encapsulation in C++ ○ You can't access private data outside the class .. 14
  • 16. Abstraction • Using simple things to represent complexity • Hide complex details from user • Abstraction is using simple classes to represent complexity. Abstraction is an extension of encapsulation. For example, you don’t have to know all the details of how the engine works to drive a car. 16
  • 17. • Lets consider this example for understanding Abstraction 17
  • 18. Abstraction • A driver only uses a small selection of tools: like gas pedal, brake, steering wheel, blinker. The engineering is hidden from the driver. To make a car work, a lot of pieces have to work under the hood, but exposing that information to the driver would be a dangerous distraction. • Abstraction also serves an important security role. By only displaying selected pieces of data, and only allowing data to be accessed through classes and modified through methods, we protect the data from exposure. To continue with the car example, you wouldn’t want an open gas tank while driving a car. 18
  • 19. • Simple, high level user interfaces • Complex code is hidden • Security • Easier software maintenance • Code updates rarely change abstraction 19 The benefits of abstraction are summarized below
  • 21. What is Inheritance? ○ Inheritance is a mechanism in which one class acquires the property of another class. ○ Reusability is an important concept of OOPs. ○ Boost the Maintainablity of the code. ○ The class from which the new class inherits properties is called BASE CLASS and the new created class is called DERIVED CLASS. ○ Syntax - class derived-class: access-specifier base-class { // data members and member functions of derived class }
  • 22. 22
  • 23. 23 Types of Inheritance Single Inheritance Multiple Inheritance Multilevel Inheritance
  • 25. 25
  • 27. Definition ○ Polymorphism means "the condition of occurring in several different forms." That's exactly what the fourth and final pillar is concerned with – types in the same inheritance chains being able to do different things. ○ The word polymorphism means having many forms. In simple words, we can define polymorphism as the ability of a message to be displayed in more than one form. ○ Polymorphism is considered as one of the important features of Object Oriented Programming. 27
  • 28. In C++ polymorphism is mainly divided into two types Compile time polymorphism: This type of polymorphism is achieved by function overloading or operator overloading. Function Overloading: Function overloading is a feature in C++ where two or more functions can have the same name but different parameters. 28
  • 29. #include<iostream> #include<stdio.h> int area(int, int); float area(int); int main() { int r; std::cout<<"Enter radius of a circle"; std::cin>>r; float A=area(r); std::cout<<"Area of Circle is "<<A; 29 int l,b,a; std::cout<<"Enter length and breadth of rectangle"; std::cin>>l>>b; a=area(l,b); std::cout<<"area of Rectangle is"<<a; } float area(int R) { return(3.14*R*R); } int area(int L,int B) { return(L*B); }
  • 30. Operator Overloading • In C++, we can make operators to work for user defined classes. This means C++ has the ability to provide the operators with a special meaning for a data type, this ability is known as operator overloading. • For example, we can overload an operator ‘+’ in a class like String so that we can concatenate two strings by just using 30
  • 31. #include<iostream> class Complex { private: int a,b; public: void setData(int x, int y) { a=x; b=y; } void showData() Complex operator +(Complex c) 31 { std::cout<<"na="<<a<<"nb="<<b; } { Complex temp; temp.a=a+c.a; temp.b=b+c.b; return(temp); } }; int main() { Complex c1,c2,c3; c1.setData(3,4); c2.setData(5,6); c3=c1+c2; c3.showData(); }
  • 32. Runtime polymorphism ○ This type of polymorphism is achieved by Function Overriding. ○ A virtual function is a member function which is declared in the base class using the keyword virtual and is re-defined (Overriden) by the derived class. 32
  • 33. #include <iostream> using namespace std; // Base class class Shape { public: Shape(int l, int w) { length = l; width = w; } // default constructor int get_Area() { 33 cout << "This is call to parent class area" << endl; } protected: int length, width; }; // Derived class class Square : public Shape { public: Square(int l = 0, int w = 0) : Shape(l, w) { } // declaring and initializing derived class // constructor
  • 34. int get_Area() { cout << "Square area: " << length * width << endl; return (length * width); } }; // Derived class class Rectangle : public Shape { public: Rectangle(int l = 0, int w = 0) : Shape(l, w) { } // declaring and initializing derived class 34 // constructor int get_Area() { cout << "Rectangle area: " << length * width<< endl; return (length * width); } }; int main(void) { Shape* s; Square sq(5, 5); // making object of child class Sqaure Rectangle rec(4, 5); // making object of child class Rectangle s = &sq; s->get_Area(); s = &rec; s->get_Area(); return 0; }
  • 35. CONCLUSION  Object-Oriented Programming has many advantages to Procedural Programming.  In OOP, data can be made private to a class such that only member functions of the class can access the data.  The objects are processed by their member data and functions. 35
  • 36. 1. https://www.linkedin.com/pulse/4-pillars-object-oriented-programming-pushkar-kumar 2. https://info.keylimeinteractive.com/the-four-pillars-of-object-oriented-programming 3. https://www.tutorialspoint.com/cplusplus/cpp_polymorphism.htm 4. https://www.guru99.com/java-class-inheritance.html#6 5. https://www.javatpoint.com/cpp-polymorphism 6. https://www.geeksforgeeks.org/encapsulation-in-c/ 7. https://www.youtube.com/watch?v=a8ZB-TPB6EU 36 RESOURCES