SlideShare a Scribd company logo
1 of 10
Download to read offline
The four pillars of object oriented programming development :
1. Encapsulation :
Encapsulation is one of the fundamental concept of OOP's. It refers
to the bundling (combining) of data with the methods (member functions that
operate on that data) into a single entity (like wrapping of data and methods
into a capsule) called an Object. It is used to hide the values or state of a
structured data object inside a class, preventing unauthorized parties, direct
access with them. Publicly accessible methods are generally provided in the
class to access the values, and other client classes call these methods to retrive
and modify the values within the object.
We generally call the functions that are declared in c++ are called
as Member functions. But in some Object Oriented languages (OO's) we call
them as Methods. Also the data members are called Attributes or Instance
variables.
Take a look with an example :
#include<iostream>
using namespace std;
class s
{
public:
For references : http://comsciguide.blogspot.com/
int count; // data member of the class
s() // constructor
{
count=0; // data member initialization
}
int disp() // method of the same class
{
return count;
}
void addcount(int a) //method of the same class
{
count=count+a;
}
};
int main()
{
s obj;
obj.addcount(1);
obj.addcount(4);
obj.addcount(9);
cout<<obj.count; // output : 14
return 0;
}
In the above example u can observe that all tha data members and
methods are binded into a object called “obj”. In Encapsulation we can declare
data members as private, protected, or public. So we can directly access the
For references : http://comsciguide.blogspot.com/
data members (here count).
Features and Advantages of concept of Encapsulation :
• Makes maintenance of program easier .
• Improves the understandability of the program.
• As the data members and functions are bundled inside the class, human
errors are reduced.
• Encapsulation is alone a powerful feature that leads to information
hiding, abstract data type and friend functions.
WWW.COMSCIGUIDE.BLOGSPOT.COM
2.Data Hiding :
The concept of encapsulation shows that a non -member function
cannot access an object's private or protected data. This has leads to the new
concept of data hiding. Data Hiding is a technique specifically used in object
oriented programming(OOP) to hide the internal object details (data members
or methods) from being accessible to outside users and unauthorised parties.
The Private access modifier was introduced to provide that protection. Thus it
keeps safe both the data and methods from outside interference and misuse. In
data hiding, the data members must be private. The programmer must
For references : http://comsciguide.blogspot.com/
explicitly define a get or set method to allow another object to read or modify
these values.
For example :
class s
{
int count; // data member of the class
// default members are private
public:
s() // constructor
{
count=0; // data member initialization
}
int disp() // method of the same class
{
return count;
}
void addcount(int a) //method of the same class
{
count=count+a;
}
};
int main()
{
s obj;
obj.addcount(1);
obj.addcount(4);
obj.addcount(9);
cout<<obj.disp();
For references : http://comsciguide.blogspot.com/
return 0;
}
Here the data member count is private. So u can't access it directly.
Instead u can access it, by the methods of the same class. Here It is accessed by
the disp method .
• In some cases of two classes, the programmer might require an unrelated
function to operate on an object of two classes. The programmer then
able to utilize the concept of friend functions.
• It enhances the security and less data complexity
• The focus of data encapsulation is on the data inside the capsule while
that data hiding is concerned with restrictions and allowance in terms of
access and use.
WWW.COMSCIGUIDE.BLOGSPOT.COM
3.Inheritance:
Reusability is yet another important feature of OOP's concept. It is
always nice, if we could reuse something instead of creating the same all over
again. For instance, the reuse of a class that has already tested and used many
times can save the effort of developing and testing it again.
For references : http://comsciguide.blogspot.com/
C++ supports the concept of reusability. Once a class has written
and tested, it can be adapted by other programmers to suit their requirements.
This is done by creating new classes, and reusing the existing properties. The
mechanism of deriving a new class from old one is called Inheritance. The old
class is referred as “Base class”. And the new one created is called as
“Derived class”.
For references : http://comsciguide.blogspot.com/
FEATURE A
FEATURE C
FEATURE B
FEATURE A
FEATURE C
FEATURE B
FEATURE D
DERIVED FROM BASE CLASSDERIVED FROM BASE CLASS
BASE CLASSBASE CLASS
DERIVED CLASSDERIVED CLASS
Here is an example :
#include<iostream>
using namespace std;
class e
{
public:
int a;
void b()
{
a=10;
}
};
class c : public e // public inheritance
{
public:
void d()
{
cout<<a<<endl;
}
};
int main()
{
c ab;
ab.b();
ab.d();
}
For references : http://comsciguide.blogspot.com/
Here a is declared in the base class e and is inherited in
the class c so that we need not to it declare again.
• Reusing existing code saves time and increases a program's reliability.
• An important result of reusability is the ease of distributing class
libraries. A programmer can use a class created by another person or
company, and without modifying it, derive other classes from it that are
suited to their requirements.
WWW.COMSCIGUIDE.BLOGSPOT.COM
4.POLYMORPHISM:
Polymorphism -- “one interface, multiple methods.”
Polymorphism occurs when there is a hierarchy of classes and they
are related by inheritance. Generally, from the Greek meaning Polymorphism
is the ability to appear in many forms (having multiple forms) and to redefine
methods for derived classes.
A real-world example of polymorphism is a thermostat. No matter
what type of furnace your house has(gas, oil, electric, etc), the thermostat
works in the same way. In this case, the thermostat (which is the interface) is
the same, no matter what type of furnace (method) you have. For example, if
For references : http://comsciguide.blogspot.com/
you want a 70-degree temperature, you set the thermostat to 70 degrees. It
doesn't matter what t ype of furnace actually provides the heat.
This same principle can also apply to programming. For example,
you might have a program that defines three different types of stacks. One stack
is used for integer values, one for character values, and one for floating-point
values. You can define one set of names, push( ) and pop( ) that can be used for
all three stacks. In your program, you will create three specific versions of
these functions, one for each type of stack, but names of the functions should be
same. The compiler will automatically select the right function based upon the
data being stored. Thus, the interface to a stack -- the functions push( ) and
pop( ), are the same no matter which type of stack is being used. The individual
versions of these functions define the specific implementations (methods) for
each type of data.
• Polymorphism reduces complexity by allowing the same interface to be
used to access class of actions. It is the compiler's job to select the
specific action (method) to each situation.
Also see :
1.Programs those work in C but not in C++
2.Difference between malloc(),calloc(),realloc()
3.Dynamic memory allocation (Stack vs Heap)
4.3 ways to solve recurrence relations
For references : http://comsciguide.blogspot.com/
WWW.COMSCIGUIDE.BLOGSPOT.COM
For references : http://comsciguide.blogspot.com/

More Related Content

What's hot

Access specifiers (Public Private Protected) C++
Access specifiers (Public Private  Protected) C++Access specifiers (Public Private  Protected) C++
Access specifiers (Public Private Protected) C++vivekkumar2938
 
Classes, objects in JAVA
Classes, objects in JAVAClasses, objects in JAVA
Classes, objects in JAVAAbhilash Nair
 
Java: Inheritance
Java: InheritanceJava: Inheritance
Java: InheritanceTareq Hasan
 
Object Oriented Concepts and Principles
Object Oriented Concepts and PrinciplesObject Oriented Concepts and Principles
Object Oriented Concepts and Principlesdeonpmeyer
 
Object Oriented Programming Concepts for beginners
Object Oriented Programming Concepts for beginners Object Oriented Programming Concepts for beginners
Object Oriented Programming Concepts for beginners Vibhawa Nirmal
 
2CPP09 - Encapsulation
2CPP09 - Encapsulation2CPP09 - Encapsulation
2CPP09 - EncapsulationMichael Heron
 
Inheritance in JAVA PPT
Inheritance  in JAVA PPTInheritance  in JAVA PPT
Inheritance in JAVA PPTPooja Jaiswal
 
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
 
Characteristics of OOPS
Characteristics of OOPS Characteristics of OOPS
Characteristics of OOPS abhishek kumar
 
Basic concepts of object oriented programming
Basic concepts of object oriented programmingBasic concepts of object oriented programming
Basic concepts of object oriented programmingSachin Sharma
 

What's hot (20)

Java Basic Oops Concept
Java Basic Oops ConceptJava Basic Oops Concept
Java Basic Oops Concept
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
 
concept of oops
concept of oopsconcept of oops
concept of oops
 
Access specifiers (Public Private Protected) C++
Access specifiers (Public Private  Protected) C++Access specifiers (Public Private  Protected) C++
Access specifiers (Public Private Protected) C++
 
Classes, objects in JAVA
Classes, objects in JAVAClasses, objects in JAVA
Classes, objects in JAVA
 
Java(Polymorphism)
Java(Polymorphism)Java(Polymorphism)
Java(Polymorphism)
 
Python-DataAbstarction.pptx
Python-DataAbstarction.pptxPython-DataAbstarction.pptx
Python-DataAbstarction.pptx
 
Inheritance
InheritanceInheritance
Inheritance
 
Java: Inheritance
Java: InheritanceJava: Inheritance
Java: Inheritance
 
Object Oriented Concepts and Principles
Object Oriented Concepts and PrinciplesObject Oriented Concepts and Principles
Object Oriented Concepts and Principles
 
Polymorphism
PolymorphismPolymorphism
Polymorphism
 
Object Oriented Programming Concepts for beginners
Object Oriented Programming Concepts for beginners Object Oriented Programming Concepts for beginners
Object Oriented Programming Concepts for beginners
 
2CPP09 - Encapsulation
2CPP09 - Encapsulation2CPP09 - Encapsulation
2CPP09 - Encapsulation
 
Data types in c++
Data types in c++Data types in c++
Data types in c++
 
Inheritance in JAVA PPT
Inheritance  in JAVA PPTInheritance  in JAVA PPT
Inheritance in JAVA PPT
 
Chapter2 Encapsulation (Java)
Chapter2 Encapsulation (Java)Chapter2 Encapsulation (Java)
Chapter2 Encapsulation (Java)
 
OOP Introduction with java programming language
OOP Introduction with java programming languageOOP Introduction with java programming language
OOP Introduction with java programming language
 
Characteristics of OOPS
Characteristics of OOPS Characteristics of OOPS
Characteristics of OOPS
 
Basic concepts of object oriented programming
Basic concepts of object oriented programmingBasic concepts of object oriented programming
Basic concepts of object oriented programming
 
Basic concept of OOP's
Basic concept of OOP'sBasic concept of OOP's
Basic concept of OOP's
 

Viewers also liked

Object Oriented Programming Concepts
Object Oriented Programming ConceptsObject Oriented Programming Concepts
Object Oriented Programming Conceptsthinkphp
 
Object oriented programming (oop) cs304 power point slides lecture 01
Object oriented programming (oop)   cs304 power point slides lecture 01Object oriented programming (oop)   cs304 power point slides lecture 01
Object oriented programming (oop) cs304 power point slides lecture 01Adil Kakakhel
 
Object Oriented Programming
Object Oriented ProgrammingObject Oriented Programming
Object Oriented ProgrammingHaris Bin Zahid
 
Object-Oriented Programming Concepts
Object-Oriented Programming ConceptsObject-Oriented Programming Concepts
Object-Oriented Programming ConceptsKwangshin Oh
 
20. Object-Oriented Programming Fundamental Principles
20. Object-Oriented Programming Fundamental Principles20. Object-Oriented Programming Fundamental Principles
20. Object-Oriented Programming Fundamental PrinciplesIntro C# Book
 
Knut Morris Pratt Algorithm
Knut Morris Pratt AlgorithmKnut Morris Pratt Algorithm
Knut Morris Pratt Algorithmthinkphp
 
Oop’s Concept and its Real Life Applications
Oop’s Concept and its Real Life ApplicationsOop’s Concept and its Real Life Applications
Oop’s Concept and its Real Life ApplicationsShar_1
 
Constructor and encapsulation in php
Constructor and encapsulation in phpConstructor and encapsulation in php
Constructor and encapsulation in phpSHIVANI SONI
 
SSRP Self Learning Guide Maths Class 10 - In Hindi
SSRP Self Learning Guide Maths Class 10 - In HindiSSRP Self Learning Guide Maths Class 10 - In Hindi
SSRP Self Learning Guide Maths Class 10 - In Hindikusumafoundation
 
Introduction - Imperative and Object-Oriented Languages
Introduction - Imperative and Object-Oriented LanguagesIntroduction - Imperative and Object-Oriented Languages
Introduction - Imperative and Object-Oriented LanguagesGuido Wachsmuth
 
Introduction to object oriented language
Introduction to object oriented languageIntroduction to object oriented language
Introduction to object oriented languagefarhan amjad
 
Cbse class 10 hindi course b model answers by candidates 2015
Cbse class 10 hindi course b model answers by candidates 2015Cbse class 10 hindi course b model answers by candidates 2015
Cbse class 10 hindi course b model answers by candidates 2015Saurabh Singh Negi
 

Viewers also liked (20)

Object Oriented Programming Concepts
Object Oriented Programming ConceptsObject Oriented Programming Concepts
Object Oriented Programming Concepts
 
Object oriented programming (oop) cs304 power point slides lecture 01
Object oriented programming (oop)   cs304 power point slides lecture 01Object oriented programming (oop)   cs304 power point slides lecture 01
Object oriented programming (oop) cs304 power point slides lecture 01
 
Oops ppt
Oops pptOops ppt
Oops ppt
 
Object Oriented Programming
Object Oriented ProgrammingObject Oriented Programming
Object Oriented Programming
 
Object-Oriented Programming Concepts
Object-Oriented Programming ConceptsObject-Oriented Programming Concepts
Object-Oriented Programming Concepts
 
Object-oriented concepts
Object-oriented conceptsObject-oriented concepts
Object-oriented concepts
 
20. Object-Oriented Programming Fundamental Principles
20. Object-Oriented Programming Fundamental Principles20. Object-Oriented Programming Fundamental Principles
20. Object-Oriented Programming Fundamental Principles
 
Knut Morris Pratt Algorithm
Knut Morris Pratt AlgorithmKnut Morris Pratt Algorithm
Knut Morris Pratt Algorithm
 
.Net slid
.Net slid.Net slid
.Net slid
 
Oop’s Concept and its Real Life Applications
Oop’s Concept and its Real Life ApplicationsOop’s Concept and its Real Life Applications
Oop’s Concept and its Real Life Applications
 
Constructor and encapsulation in php
Constructor and encapsulation in phpConstructor and encapsulation in php
Constructor and encapsulation in php
 
Oops
OopsOops
Oops
 
SSRP Self Learning Guide Maths Class 10 - In Hindi
SSRP Self Learning Guide Maths Class 10 - In HindiSSRP Self Learning Guide Maths Class 10 - In Hindi
SSRP Self Learning Guide Maths Class 10 - In Hindi
 
Unit i
Unit iUnit i
Unit i
 
Labsheet2
Labsheet2Labsheet2
Labsheet2
 
Labsheet_3
Labsheet_3Labsheet_3
Labsheet_3
 
Oops Concepts
Oops ConceptsOops Concepts
Oops Concepts
 
Introduction - Imperative and Object-Oriented Languages
Introduction - Imperative and Object-Oriented LanguagesIntroduction - Imperative and Object-Oriented Languages
Introduction - Imperative and Object-Oriented Languages
 
Introduction to object oriented language
Introduction to object oriented languageIntroduction to object oriented language
Introduction to object oriented language
 
Cbse class 10 hindi course b model answers by candidates 2015
Cbse class 10 hindi course b model answers by candidates 2015Cbse class 10 hindi course b model answers by candidates 2015
Cbse class 10 hindi course b model answers by candidates 2015
 

Similar to 4 pillars of OOPS CONCEPT

Similar to 4 pillars of OOPS CONCEPT (20)

My c++
My c++My c++
My c++
 
Interoduction to c++
Interoduction to c++Interoduction to c++
Interoduction to c++
 
OOP interview questions & answers.
OOP interview questions & answers.OOP interview questions & answers.
OOP interview questions & answers.
 
Php oop (1)
Php oop (1)Php oop (1)
Php oop (1)
 
OOP lesson1 and Variables.pdf
OOP lesson1 and Variables.pdfOOP lesson1 and Variables.pdf
OOP lesson1 and Variables.pdf
 
Object-oriented programming (OOP) with Complete understanding modules
Object-oriented programming (OOP) with Complete understanding modulesObject-oriented programming (OOP) with Complete understanding modules
Object-oriented programming (OOP) with Complete understanding modules
 
Introduction to Java -unit-1
Introduction to Java -unit-1Introduction to Java -unit-1
Introduction to Java -unit-1
 
I assignmnt(oops)
I assignmnt(oops)I assignmnt(oops)
I assignmnt(oops)
 
Opp concept in c++
Opp concept in c++Opp concept in c++
Opp concept in c++
 
Object Oriented Programming
Object Oriented ProgrammingObject Oriented Programming
Object Oriented Programming
 
Mca 504 dotnet_unit3
Mca 504 dotnet_unit3Mca 504 dotnet_unit3
Mca 504 dotnet_unit3
 
Unit 5.ppt
Unit 5.pptUnit 5.ppt
Unit 5.ppt
 
Diving in OOP (Day 1) : Polymorphism and Inheritance (Early Binding/Compile T...
Diving in OOP (Day 1) : Polymorphism and Inheritance (Early Binding/Compile T...Diving in OOP (Day 1) : Polymorphism and Inheritance (Early Binding/Compile T...
Diving in OOP (Day 1) : Polymorphism and Inheritance (Early Binding/Compile T...
 
C++ Version 2
C++  Version 2C++  Version 2
C++ Version 2
 
Selenium Training .pptx
Selenium Training .pptxSelenium Training .pptx
Selenium Training .pptx
 
The smartpath information systems c plus plus
The smartpath information systems  c plus plusThe smartpath information systems  c plus plus
The smartpath information systems c plus plus
 
C++Day-1 Introduction.ppt
C++Day-1 Introduction.pptC++Day-1 Introduction.ppt
C++Day-1 Introduction.ppt
 
OOP-Advanced Programming with c++
OOP-Advanced Programming with c++OOP-Advanced Programming with c++
OOP-Advanced Programming with c++
 
OOP-Advanced_Programming.pptx
OOP-Advanced_Programming.pptxOOP-Advanced_Programming.pptx
OOP-Advanced_Programming.pptx
 
Oops
OopsOops
Oops
 

More from Ajay Chimmani

24 standard interview puzzles - Secret mail puzzle
24 standard interview puzzles - Secret mail puzzle24 standard interview puzzles - Secret mail puzzle
24 standard interview puzzles - Secret mail puzzleAjay Chimmani
 
24 standard interview puzzles - The pot of beans
24 standard interview puzzles - The pot of beans24 standard interview puzzles - The pot of beans
24 standard interview puzzles - The pot of beansAjay Chimmani
 
24 standard interview puzzles - How strog is an egg
24 standard interview puzzles - How strog is an egg24 standard interview puzzles - How strog is an egg
24 standard interview puzzles - How strog is an eggAjay Chimmani
 
24 standard interview puzzles - 4 men in hats
24 standard interview puzzles - 4 men in hats24 standard interview puzzles - 4 men in hats
24 standard interview puzzles - 4 men in hatsAjay Chimmani
 
Aptitude Training - TIME AND DISTANCE 3
Aptitude Training - TIME AND DISTANCE 3Aptitude Training - TIME AND DISTANCE 3
Aptitude Training - TIME AND DISTANCE 3Ajay Chimmani
 
Aptitude Training - PIPES AND CISTERN
Aptitude Training - PIPES AND CISTERNAptitude Training - PIPES AND CISTERN
Aptitude Training - PIPES AND CISTERNAjay Chimmani
 
Aptitude Training - PROFIT AND LOSS
Aptitude Training - PROFIT AND LOSSAptitude Training - PROFIT AND LOSS
Aptitude Training - PROFIT AND LOSSAjay Chimmani
 
Aptitude Training - SOLID GEOMETRY 1
Aptitude Training - SOLID GEOMETRY 1Aptitude Training - SOLID GEOMETRY 1
Aptitude Training - SOLID GEOMETRY 1Ajay Chimmani
 
Aptitude Training - SIMPLE AND COMPOUND INTEREST
Aptitude Training - SIMPLE AND COMPOUND INTERESTAptitude Training - SIMPLE AND COMPOUND INTEREST
Aptitude Training - SIMPLE AND COMPOUND INTERESTAjay Chimmani
 
Aptitude Training - TIME AND DISTANCE 4
Aptitude Training - TIME AND DISTANCE 4Aptitude Training - TIME AND DISTANCE 4
Aptitude Training - TIME AND DISTANCE 4Ajay Chimmani
 
Aptitude Training - TIME AND DISTANCE 1
Aptitude Training - TIME AND DISTANCE 1Aptitude Training - TIME AND DISTANCE 1
Aptitude Training - TIME AND DISTANCE 1Ajay Chimmani
 
Aptitude Training - PROBLEMS ON CUBES
Aptitude Training - PROBLEMS ON CUBESAptitude Training - PROBLEMS ON CUBES
Aptitude Training - PROBLEMS ON CUBESAjay Chimmani
 
Aptitude Training - RATIO AND PROPORTION 1
Aptitude Training - RATIO AND PROPORTION 1Aptitude Training - RATIO AND PROPORTION 1
Aptitude Training - RATIO AND PROPORTION 1Ajay Chimmani
 
Aptitude Training - PROBABILITY
Aptitude Training - PROBABILITYAptitude Training - PROBABILITY
Aptitude Training - PROBABILITYAjay Chimmani
 
Aptitude Training - RATIO AND PROPORTION 4
Aptitude Training - RATIO AND PROPORTION 4Aptitude Training - RATIO AND PROPORTION 4
Aptitude Training - RATIO AND PROPORTION 4Ajay Chimmani
 
Aptitude Training - NUMBERS
Aptitude Training - NUMBERSAptitude Training - NUMBERS
Aptitude Training - NUMBERSAjay Chimmani
 
Aptitude Training - RATIO AND PROPORTION 2
Aptitude Training - RATIO AND PROPORTION 2Aptitude Training - RATIO AND PROPORTION 2
Aptitude Training - RATIO AND PROPORTION 2Ajay Chimmani
 
Aptitude Training - PERMUTATIONS AND COMBINATIONS 2
Aptitude Training - PERMUTATIONS AND COMBINATIONS 2Aptitude Training - PERMUTATIONS AND COMBINATIONS 2
Aptitude Training - PERMUTATIONS AND COMBINATIONS 2Ajay Chimmani
 
Aptitude Training - PERCENTAGE 2
Aptitude Training - PERCENTAGE 2Aptitude Training - PERCENTAGE 2
Aptitude Training - PERCENTAGE 2Ajay Chimmani
 
Aptitude Training - PERCENTAGE 1
Aptitude Training - PERCENTAGE 1Aptitude Training - PERCENTAGE 1
Aptitude Training - PERCENTAGE 1Ajay Chimmani
 

More from Ajay Chimmani (20)

24 standard interview puzzles - Secret mail puzzle
24 standard interview puzzles - Secret mail puzzle24 standard interview puzzles - Secret mail puzzle
24 standard interview puzzles - Secret mail puzzle
 
24 standard interview puzzles - The pot of beans
24 standard interview puzzles - The pot of beans24 standard interview puzzles - The pot of beans
24 standard interview puzzles - The pot of beans
 
24 standard interview puzzles - How strog is an egg
24 standard interview puzzles - How strog is an egg24 standard interview puzzles - How strog is an egg
24 standard interview puzzles - How strog is an egg
 
24 standard interview puzzles - 4 men in hats
24 standard interview puzzles - 4 men in hats24 standard interview puzzles - 4 men in hats
24 standard interview puzzles - 4 men in hats
 
Aptitude Training - TIME AND DISTANCE 3
Aptitude Training - TIME AND DISTANCE 3Aptitude Training - TIME AND DISTANCE 3
Aptitude Training - TIME AND DISTANCE 3
 
Aptitude Training - PIPES AND CISTERN
Aptitude Training - PIPES AND CISTERNAptitude Training - PIPES AND CISTERN
Aptitude Training - PIPES AND CISTERN
 
Aptitude Training - PROFIT AND LOSS
Aptitude Training - PROFIT AND LOSSAptitude Training - PROFIT AND LOSS
Aptitude Training - PROFIT AND LOSS
 
Aptitude Training - SOLID GEOMETRY 1
Aptitude Training - SOLID GEOMETRY 1Aptitude Training - SOLID GEOMETRY 1
Aptitude Training - SOLID GEOMETRY 1
 
Aptitude Training - SIMPLE AND COMPOUND INTEREST
Aptitude Training - SIMPLE AND COMPOUND INTERESTAptitude Training - SIMPLE AND COMPOUND INTEREST
Aptitude Training - SIMPLE AND COMPOUND INTEREST
 
Aptitude Training - TIME AND DISTANCE 4
Aptitude Training - TIME AND DISTANCE 4Aptitude Training - TIME AND DISTANCE 4
Aptitude Training - TIME AND DISTANCE 4
 
Aptitude Training - TIME AND DISTANCE 1
Aptitude Training - TIME AND DISTANCE 1Aptitude Training - TIME AND DISTANCE 1
Aptitude Training - TIME AND DISTANCE 1
 
Aptitude Training - PROBLEMS ON CUBES
Aptitude Training - PROBLEMS ON CUBESAptitude Training - PROBLEMS ON CUBES
Aptitude Training - PROBLEMS ON CUBES
 
Aptitude Training - RATIO AND PROPORTION 1
Aptitude Training - RATIO AND PROPORTION 1Aptitude Training - RATIO AND PROPORTION 1
Aptitude Training - RATIO AND PROPORTION 1
 
Aptitude Training - PROBABILITY
Aptitude Training - PROBABILITYAptitude Training - PROBABILITY
Aptitude Training - PROBABILITY
 
Aptitude Training - RATIO AND PROPORTION 4
Aptitude Training - RATIO AND PROPORTION 4Aptitude Training - RATIO AND PROPORTION 4
Aptitude Training - RATIO AND PROPORTION 4
 
Aptitude Training - NUMBERS
Aptitude Training - NUMBERSAptitude Training - NUMBERS
Aptitude Training - NUMBERS
 
Aptitude Training - RATIO AND PROPORTION 2
Aptitude Training - RATIO AND PROPORTION 2Aptitude Training - RATIO AND PROPORTION 2
Aptitude Training - RATIO AND PROPORTION 2
 
Aptitude Training - PERMUTATIONS AND COMBINATIONS 2
Aptitude Training - PERMUTATIONS AND COMBINATIONS 2Aptitude Training - PERMUTATIONS AND COMBINATIONS 2
Aptitude Training - PERMUTATIONS AND COMBINATIONS 2
 
Aptitude Training - PERCENTAGE 2
Aptitude Training - PERCENTAGE 2Aptitude Training - PERCENTAGE 2
Aptitude Training - PERCENTAGE 2
 
Aptitude Training - PERCENTAGE 1
Aptitude Training - PERCENTAGE 1Aptitude Training - PERCENTAGE 1
Aptitude Training - PERCENTAGE 1
 

Recently uploaded

Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Celine George
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designMIPLM
 
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...JojoEDelaCruz
 
EMBODO Lesson Plan Grade 9 Law of Sines.docx
EMBODO Lesson Plan Grade 9 Law of Sines.docxEMBODO Lesson Plan Grade 9 Law of Sines.docx
EMBODO Lesson Plan Grade 9 Law of Sines.docxElton John Embodo
 
Dust Of Snow By Robert Frost Class-X English CBSE
Dust Of Snow By Robert Frost Class-X English CBSEDust Of Snow By Robert Frost Class-X English CBSE
Dust Of Snow By Robert Frost Class-X English CBSEaurabinda banchhor
 
The Contemporary World: The Globalization of World Politics
The Contemporary World: The Globalization of World PoliticsThe Contemporary World: The Globalization of World Politics
The Contemporary World: The Globalization of World PoliticsRommel Regala
 
Integumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.pptIntegumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.pptshraddhaparab530
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONHumphrey A Beña
 
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxQ4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxlancelewisportillo
 
Active Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfActive Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfPatidar M
 
Activity 2-unit 2-update 2024. English translation
Activity 2-unit 2-update 2024. English translationActivity 2-unit 2-update 2024. English translation
Activity 2-unit 2-update 2024. English translationRosabel UA
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSJoshuaGantuangco2
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...Postal Advocate Inc.
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management systemChristalin Nelson
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxAnupkumar Sharma
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPCeline George
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfTechSoup
 
Presentation Activity 2. Unit 3 transv.pptx
Presentation Activity 2. Unit 3 transv.pptxPresentation Activity 2. Unit 3 transv.pptx
Presentation Activity 2. Unit 3 transv.pptxRosabel UA
 

Recently uploaded (20)

Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-design
 
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
 
EMBODO Lesson Plan Grade 9 Law of Sines.docx
EMBODO Lesson Plan Grade 9 Law of Sines.docxEMBODO Lesson Plan Grade 9 Law of Sines.docx
EMBODO Lesson Plan Grade 9 Law of Sines.docx
 
Dust Of Snow By Robert Frost Class-X English CBSE
Dust Of Snow By Robert Frost Class-X English CBSEDust Of Snow By Robert Frost Class-X English CBSE
Dust Of Snow By Robert Frost Class-X English CBSE
 
The Contemporary World: The Globalization of World Politics
The Contemporary World: The Globalization of World PoliticsThe Contemporary World: The Globalization of World Politics
The Contemporary World: The Globalization of World Politics
 
Integumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.pptIntegumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.ppt
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
 
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxQ4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
 
Active Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfActive Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdf
 
Activity 2-unit 2-update 2024. English translation
Activity 2-unit 2-update 2024. English translationActivity 2-unit 2-update 2024. English translation
Activity 2-unit 2-update 2024. English translation
 
INCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptx
INCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptxINCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptx
INCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptx
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management system
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
 
Presentation Activity 2. Unit 3 transv.pptx
Presentation Activity 2. Unit 3 transv.pptxPresentation Activity 2. Unit 3 transv.pptx
Presentation Activity 2. Unit 3 transv.pptx
 
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptxYOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
 

4 pillars of OOPS CONCEPT

  • 1. The four pillars of object oriented programming development : 1. Encapsulation : Encapsulation is one of the fundamental concept of OOP's. It refers to the bundling (combining) of data with the methods (member functions that operate on that data) into a single entity (like wrapping of data and methods into a capsule) called an Object. It is used to hide the values or state of a structured data object inside a class, preventing unauthorized parties, direct access with them. Publicly accessible methods are generally provided in the class to access the values, and other client classes call these methods to retrive and modify the values within the object. We generally call the functions that are declared in c++ are called as Member functions. But in some Object Oriented languages (OO's) we call them as Methods. Also the data members are called Attributes or Instance variables. Take a look with an example : #include<iostream> using namespace std; class s { public: For references : http://comsciguide.blogspot.com/
  • 2. int count; // data member of the class s() // constructor { count=0; // data member initialization } int disp() // method of the same class { return count; } void addcount(int a) //method of the same class { count=count+a; } }; int main() { s obj; obj.addcount(1); obj.addcount(4); obj.addcount(9); cout<<obj.count; // output : 14 return 0; } In the above example u can observe that all tha data members and methods are binded into a object called “obj”. In Encapsulation we can declare data members as private, protected, or public. So we can directly access the For references : http://comsciguide.blogspot.com/
  • 3. data members (here count). Features and Advantages of concept of Encapsulation : • Makes maintenance of program easier . • Improves the understandability of the program. • As the data members and functions are bundled inside the class, human errors are reduced. • Encapsulation is alone a powerful feature that leads to information hiding, abstract data type and friend functions. WWW.COMSCIGUIDE.BLOGSPOT.COM 2.Data Hiding : The concept of encapsulation shows that a non -member function cannot access an object's private or protected data. This has leads to the new concept of data hiding. Data Hiding is a technique specifically used in object oriented programming(OOP) to hide the internal object details (data members or methods) from being accessible to outside users and unauthorised parties. The Private access modifier was introduced to provide that protection. Thus it keeps safe both the data and methods from outside interference and misuse. In data hiding, the data members must be private. The programmer must For references : http://comsciguide.blogspot.com/
  • 4. explicitly define a get or set method to allow another object to read or modify these values. For example : class s { int count; // data member of the class // default members are private public: s() // constructor { count=0; // data member initialization } int disp() // method of the same class { return count; } void addcount(int a) //method of the same class { count=count+a; } }; int main() { s obj; obj.addcount(1); obj.addcount(4); obj.addcount(9); cout<<obj.disp(); For references : http://comsciguide.blogspot.com/
  • 5. return 0; } Here the data member count is private. So u can't access it directly. Instead u can access it, by the methods of the same class. Here It is accessed by the disp method . • In some cases of two classes, the programmer might require an unrelated function to operate on an object of two classes. The programmer then able to utilize the concept of friend functions. • It enhances the security and less data complexity • The focus of data encapsulation is on the data inside the capsule while that data hiding is concerned with restrictions and allowance in terms of access and use. WWW.COMSCIGUIDE.BLOGSPOT.COM 3.Inheritance: Reusability is yet another important feature of OOP's concept. It is always nice, if we could reuse something instead of creating the same all over again. For instance, the reuse of a class that has already tested and used many times can save the effort of developing and testing it again. For references : http://comsciguide.blogspot.com/
  • 6. C++ supports the concept of reusability. Once a class has written and tested, it can be adapted by other programmers to suit their requirements. This is done by creating new classes, and reusing the existing properties. The mechanism of deriving a new class from old one is called Inheritance. The old class is referred as “Base class”. And the new one created is called as “Derived class”. For references : http://comsciguide.blogspot.com/ FEATURE A FEATURE C FEATURE B FEATURE A FEATURE C FEATURE B FEATURE D DERIVED FROM BASE CLASSDERIVED FROM BASE CLASS BASE CLASSBASE CLASS DERIVED CLASSDERIVED CLASS
  • 7. Here is an example : #include<iostream> using namespace std; class e { public: int a; void b() { a=10; } }; class c : public e // public inheritance { public: void d() { cout<<a<<endl; } }; int main() { c ab; ab.b(); ab.d(); } For references : http://comsciguide.blogspot.com/
  • 8. Here a is declared in the base class e and is inherited in the class c so that we need not to it declare again. • Reusing existing code saves time and increases a program's reliability. • An important result of reusability is the ease of distributing class libraries. A programmer can use a class created by another person or company, and without modifying it, derive other classes from it that are suited to their requirements. WWW.COMSCIGUIDE.BLOGSPOT.COM 4.POLYMORPHISM: Polymorphism -- “one interface, multiple methods.” Polymorphism occurs when there is a hierarchy of classes and they are related by inheritance. Generally, from the Greek meaning Polymorphism is the ability to appear in many forms (having multiple forms) and to redefine methods for derived classes. A real-world example of polymorphism is a thermostat. No matter what type of furnace your house has(gas, oil, electric, etc), the thermostat works in the same way. In this case, the thermostat (which is the interface) is the same, no matter what type of furnace (method) you have. For example, if For references : http://comsciguide.blogspot.com/
  • 9. you want a 70-degree temperature, you set the thermostat to 70 degrees. It doesn't matter what t ype of furnace actually provides the heat. This same principle can also apply to programming. For example, you might have a program that defines three different types of stacks. One stack is used for integer values, one for character values, and one for floating-point values. You can define one set of names, push( ) and pop( ) that can be used for all three stacks. In your program, you will create three specific versions of these functions, one for each type of stack, but names of the functions should be same. The compiler will automatically select the right function based upon the data being stored. Thus, the interface to a stack -- the functions push( ) and pop( ), are the same no matter which type of stack is being used. The individual versions of these functions define the specific implementations (methods) for each type of data. • Polymorphism reduces complexity by allowing the same interface to be used to access class of actions. It is the compiler's job to select the specific action (method) to each situation. Also see : 1.Programs those work in C but not in C++ 2.Difference between malloc(),calloc(),realloc() 3.Dynamic memory allocation (Stack vs Heap) 4.3 ways to solve recurrence relations For references : http://comsciguide.blogspot.com/
  • 10. WWW.COMSCIGUIDE.BLOGSPOT.COM For references : http://comsciguide.blogspot.com/