SlideShare a Scribd company logo
7
Most read
19
Most read
22
Most read
Introduction to Object
Oriented Programming
Language (OOPS) in C++
PROGRAMMING PARADIGM
Programming
Paradigms
Imperative
Programming
Procedural (C)
Object Oriented
Programming
(C++, Java)
Declarative
Programming
Functional
(Haskell)
Logic (Prolog)
STRUCTURED/ PROCEDURAL LANGUAGE
TOP- DOWN
APPROACH
PROGRAM
MODULE 1
MODULE 3 MODULE 4
MODULE 2
MODULE 5
EXAMPLES OF
STRUCTURED
LANGUAGE
FORTRAN
PASCAL
ALGOL
COBOL
BASIC
C
WHAT IS
OOP stands for Object-Oriented Programming
Features of OOPS
Encapsulation
Abstraction
Inheritance
Polymorphism
1. ENCAPSULATION
It is a process of wrapping of data and methods in a single unit
CLASS and OBJECT
CLASS OBJECT
Class is a container which collects
variables and methods
Object is an instance of a class
It is mere a blueprint to which no
memory is allocated at the time of
declaration
Sufficient memory space will be
allocated for the variables of class
at the time of declaration
One class definition should exist
only once in the program
For one class multiple objects can
be created.
Concept of OOPS with real life examples
Concept of OOPS with real life examples
SYNTAX:
CLASS OBJECT
class class_name
{
access specifier:
data members;
member funtions()
};
class_name object_reference;
<header files>
class addition
{ private:
int a, b, sum;
public:
void input()
{
cout<< “Enter two numbers”;
cin>>a>>b;
}
void add()
{
sum=a+b;
}
void output()
{
cout<< “Sum of two number is= “<<sum;
}
};
void main()
{
addition ob;
ob. input();
ob. add();
ob.output();
getch();
}
Enter two numbers
10
20
Sum of two number is= 30
OUTPUT
Data members
Input() add() output() are the
member functions
Object
initialization
Dot operator is
used for calling
<header files>
class addition
{
int a, b, sum;
public:
void add()
{
cout<< “Enter two numbers”;
cin>>a>>b;
sum=a+b;
cout<< “Sum of two number is= “<<sum;
}
};
void main()
{
clrscr();
addition ob;
ob. add();
getch();
}
Enter two numbers
10
20
Sum of two number is= 30
OUTPUT
2. Abstraction
Abstraction means displaying only essential information and
hiding the details
<header files>
class addition
{
int a, b, sum;
public:
void add()
{
cout<< “Enter two numbers”;
cin>>a>>b;
sum=a+b;
cout<< “Sum of two number is=
“<<sum;
}
};
void main()
{
addition ob;
ob. a= 10;
ob. b=20;
ob. add();
getch();
}
Using Access Specifier in
Class
Public:
Accessible
both inside
and outside
the class
Private:
Accessible
inside the
class but not
outside the
class
Protected:
accessible
inside the
class and
only in
inherited
classes
//Error; a and b not accessible
outside the class because they
are declared private
3. INHERITANCE
It is a mechanism in which one class acquires the property of another class.
Derived Class (child)
• The class that inherits
from another class
Base Class (Parent)
• The class being
inherited from
Concept of OOPS with real life examples
Syntax:
class base_class
{
//Body of base class
};
class derived_class : access_specifier base_class
{
//Body of derived class
};
Base Class
Derived Class
4. Polymorphism
Polymorphism means "one interface, multiple forms"
class Animal {
public:
void animalSound() {
cout << "The animal makes a sound n" ;
}
};
class Pig : public Animal {
public:
void animalSound() {
cout << "The pig says: wee wee n" ;
}
};
class Dog : public Animal {
public:
void animalSound() {
cout << "The dog says: bow wow n" ;
}
};
void main() {
Animal myAnimal;
Pig myPig;
Dog myDog;
myAnimal.animalSound();
myPig.animalSound();
myDog.animalSound();
}
OUTPUT
The animal makes a sound
The pig says: wee wee
The dog says: bow wow
Base Class (Animal)
Derived Class (Pig)
Derived Class (Dog)
class Animal {
public:
void animalSound() {
cout << "The animal makes a sound n" ;
}
};
class Pig : public Animal {
public:
void animalSound() {
cout << "The pig says: wee wee n" ;
}
};
class Dog : public Animal {
public:
void animalSound() {
cout << "The dog says: bow wow n" ;
}
};
void main() {
Animal myAnimal;
Pig myPig;
Dog myDog;
myAnimal.animalSound();
myPig.animalSound();
myDog.animalSound();
}
OUTPUT
The animal makes a sound
The pig says: wee wee
The dog says: bow wow
Base Class (Animal)
Derived Class (Pig)
Derived Class (Dog)
Conclusion
Structured Programming
..
.. ..
..
..

More Related Content

What's hot (20)

PPTX
Inheritance in Object Oriented Programming
Ashita Agrawal
 
PPTX
Inheritance in c++
Paumil Patel
 
PDF
Inheritance In Java
Arnab Bhaumik
 
PPTX
Polymorphism
Arif Ansari
 
PPTX
Polymorphism in c++(ppt)
Sanjit Shaw
 
PPTX
Polymorphism In c++
Vishesh Jha
 
PPT
Object Oriented Programming Concepts
thinkphp
 
PPT
Inheritance in java
Lovely Professional University
 
PPT
friend function(c++)
Ritika Sharma
 
PPTX
Java Inheritance
VINOTH R
 
PPTX
Java abstract class & abstract methods
Shubham Dwivedi
 
PPTX
Inheritance in oops
Hirra Sultan
 
PPT
Inheritance in c++ ppt (Powerpoint) | inheritance in c++ ppt presentation | i...
cprogrammings
 
PPTX
Method overloading
Lovely Professional University
 
PPTX
Inheritance in java
Tech_MX
 
PPTX
Polymorphism in java
Elizabeth alexander
 
PPTX
07. Virtual Functions
Haresh Jaiswal
 
PPTX
C++ Inheritance Tutorial | Introduction To Inheritance In C++ Programming Wit...
Simplilearn
 
PPTX
Oop c++class(final).ppt
Alok Kumar
 
PPTX
Abstract class in c++
Sujan Mia
 
Inheritance in Object Oriented Programming
Ashita Agrawal
 
Inheritance in c++
Paumil Patel
 
Inheritance In Java
Arnab Bhaumik
 
Polymorphism
Arif Ansari
 
Polymorphism in c++(ppt)
Sanjit Shaw
 
Polymorphism In c++
Vishesh Jha
 
Object Oriented Programming Concepts
thinkphp
 
Inheritance in java
Lovely Professional University
 
friend function(c++)
Ritika Sharma
 
Java Inheritance
VINOTH R
 
Java abstract class & abstract methods
Shubham Dwivedi
 
Inheritance in oops
Hirra Sultan
 
Inheritance in c++ ppt (Powerpoint) | inheritance in c++ ppt presentation | i...
cprogrammings
 
Method overloading
Lovely Professional University
 
Inheritance in java
Tech_MX
 
Polymorphism in java
Elizabeth alexander
 
07. Virtual Functions
Haresh Jaiswal
 
C++ Inheritance Tutorial | Introduction To Inheritance In C++ Programming Wit...
Simplilearn
 
Oop c++class(final).ppt
Alok Kumar
 
Abstract class in c++
Sujan Mia
 

Similar to Concept of OOPS with real life examples (20)

PDF
inheritance-16031525566nbhij56604452.pdf
kashafishfaq21
 
PPTX
Inheritance
Amit Dixit
 
PPTX
Concepts of oop1
SheetalPareek
 
PPTX
Opp concept in c++
SadiqullahGhani1
 
PPTX
oop.pptx
KabitaParajuli3
 
PPTX
EASY TO LEARN INHERITANCE IN C++
Nikunj Patel
 
PPTX
Inheritance in java
Ariful Islam
 
PPTX
Relationship of inheritance in oopm.pptx
ayush626953
 
PPTX
Aryan's pres. entation.pptx
mohitsinha7739289047
 
PPTX
encapsulation, inheritance, overriding, overloading
Shivam Singhal
 
PPTX
arthimetic operator,classes,objects,instant
ssuser77162c
 
PPTX
Inheritance (with classifications)
Redwan Islam
 
PPTX
Inheritance
sourav verma
 
PPTX
OOPS Characteristics (With Examples in PHP)
baabtra.com - No. 1 supplier of quality freshers
 
PDF
Programming in Java Unit 1 lesson Notes for Java for Elearners
ssuserd0b11b
 
PDF
Inheritance
Pranali Chaudhari
 
PPTX
Pi j3.1 inheritance
mcollison
 
PPT
inheritance
Amir_Mukhtar
 
inheritance-16031525566nbhij56604452.pdf
kashafishfaq21
 
Inheritance
Amit Dixit
 
Concepts of oop1
SheetalPareek
 
Opp concept in c++
SadiqullahGhani1
 
oop.pptx
KabitaParajuli3
 
EASY TO LEARN INHERITANCE IN C++
Nikunj Patel
 
Inheritance in java
Ariful Islam
 
Relationship of inheritance in oopm.pptx
ayush626953
 
Aryan's pres. entation.pptx
mohitsinha7739289047
 
encapsulation, inheritance, overriding, overloading
Shivam Singhal
 
arthimetic operator,classes,objects,instant
ssuser77162c
 
Inheritance (with classifications)
Redwan Islam
 
Inheritance
sourav verma
 
OOPS Characteristics (With Examples in PHP)
baabtra.com - No. 1 supplier of quality freshers
 
Programming in Java Unit 1 lesson Notes for Java for Elearners
ssuserd0b11b
 
Inheritance
Pranali Chaudhari
 
Pi j3.1 inheritance
mcollison
 
inheritance
Amir_Mukhtar
 
Ad

Recently uploaded (20)

PDF
Basic_Concepts_in_Clinical_Biochemistry_2018كيمياء_عملي.pdf
AdelLoin
 
DOCX
8th International Conference on Electrical Engineering (ELEN 2025)
elelijjournal653
 
PPTX
Introduction to Design of Machine Elements
PradeepKumarS27
 
DOC
MRRS Strength and Durability of Concrete
CivilMythili
 
PPTX
Mechanical Design of shell and tube heat exchangers as per ASME Sec VIII Divi...
shahveer210504
 
PDF
Unified_Cloud_Comm_Presentation anil singh ppt
anilsingh298751
 
PPTX
GitOps_Repo_Structure for begeinner(Scaffolindg)
DanialHabibi2
 
PPTX
Product Development & DevelopmentLecture02.pptx
zeeshanwazir2
 
PPTX
265587293-NFPA 101 Life safety code-PPT-1.pptx
chandermwason
 
PPTX
Arduino Based Gas Leakage Detector Project
CircuitDigest
 
DOCX
CS-802 (A) BDH Lab manual IPS Academy Indore
thegodhimself05
 
PPTX
Introduction to Neural Networks and Perceptron Learning Algorithm.pptx
Kayalvizhi A
 
PPTX
美国电子版毕业证南卡罗莱纳大学上州分校水印成绩单USC学费发票定做学位证书编号怎么查
Taqyea
 
PPT
PPT2_Metal formingMECHANICALENGINEEIRNG .ppt
Praveen Kumar
 
PPTX
The Role of Information Technology in Environmental Protectio....pptx
nallamillisriram
 
PPTX
GitOps_Without_K8s_Training simple one without k8s
DanialHabibi2
 
PDF
Zilliz Cloud Demo for performance and scale
Zilliz
 
PPTX
VITEEE 2026 Exam Details , Important Dates
SonaliSingh127098
 
PPTX
Element 11. ELECTRICITY safety and hazards
merrandomohandas
 
PPTX
GitOps_Without_K8s_Training_detailed git repository
DanialHabibi2
 
Basic_Concepts_in_Clinical_Biochemistry_2018كيمياء_عملي.pdf
AdelLoin
 
8th International Conference on Electrical Engineering (ELEN 2025)
elelijjournal653
 
Introduction to Design of Machine Elements
PradeepKumarS27
 
MRRS Strength and Durability of Concrete
CivilMythili
 
Mechanical Design of shell and tube heat exchangers as per ASME Sec VIII Divi...
shahveer210504
 
Unified_Cloud_Comm_Presentation anil singh ppt
anilsingh298751
 
GitOps_Repo_Structure for begeinner(Scaffolindg)
DanialHabibi2
 
Product Development & DevelopmentLecture02.pptx
zeeshanwazir2
 
265587293-NFPA 101 Life safety code-PPT-1.pptx
chandermwason
 
Arduino Based Gas Leakage Detector Project
CircuitDigest
 
CS-802 (A) BDH Lab manual IPS Academy Indore
thegodhimself05
 
Introduction to Neural Networks and Perceptron Learning Algorithm.pptx
Kayalvizhi A
 
美国电子版毕业证南卡罗莱纳大学上州分校水印成绩单USC学费发票定做学位证书编号怎么查
Taqyea
 
PPT2_Metal formingMECHANICALENGINEEIRNG .ppt
Praveen Kumar
 
The Role of Information Technology in Environmental Protectio....pptx
nallamillisriram
 
GitOps_Without_K8s_Training simple one without k8s
DanialHabibi2
 
Zilliz Cloud Demo for performance and scale
Zilliz
 
VITEEE 2026 Exam Details , Important Dates
SonaliSingh127098
 
Element 11. ELECTRICITY safety and hazards
merrandomohandas
 
GitOps_Without_K8s_Training_detailed git repository
DanialHabibi2
 
Ad

Concept of OOPS with real life examples

  • 1. Introduction to Object Oriented Programming Language (OOPS) in C++
  • 2. PROGRAMMING PARADIGM Programming Paradigms Imperative Programming Procedural (C) Object Oriented Programming (C++, Java) Declarative Programming Functional (Haskell) Logic (Prolog)
  • 3. STRUCTURED/ PROCEDURAL LANGUAGE TOP- DOWN APPROACH PROGRAM MODULE 1 MODULE 3 MODULE 4 MODULE 2 MODULE 5
  • 5. WHAT IS OOP stands for Object-Oriented Programming
  • 7. 1. ENCAPSULATION It is a process of wrapping of data and methods in a single unit
  • 8. CLASS and OBJECT CLASS OBJECT Class is a container which collects variables and methods Object is an instance of a class It is mere a blueprint to which no memory is allocated at the time of declaration Sufficient memory space will be allocated for the variables of class at the time of declaration One class definition should exist only once in the program For one class multiple objects can be created.
  • 11. SYNTAX: CLASS OBJECT class class_name { access specifier: data members; member funtions() }; class_name object_reference;
  • 12. <header files> class addition { private: int a, b, sum; public: void input() { cout<< “Enter two numbers”; cin>>a>>b; } void add() { sum=a+b; } void output() { cout<< “Sum of two number is= “<<sum; } }; void main() { addition ob; ob. input(); ob. add(); ob.output(); getch(); } Enter two numbers 10 20 Sum of two number is= 30 OUTPUT Data members Input() add() output() are the member functions Object initialization Dot operator is used for calling
  • 13. <header files> class addition { int a, b, sum; public: void add() { cout<< “Enter two numbers”; cin>>a>>b; sum=a+b; cout<< “Sum of two number is= “<<sum; } }; void main() { clrscr(); addition ob; ob. add(); getch(); } Enter two numbers 10 20 Sum of two number is= 30 OUTPUT
  • 14. 2. Abstraction Abstraction means displaying only essential information and hiding the details
  • 15. <header files> class addition { int a, b, sum; public: void add() { cout<< “Enter two numbers”; cin>>a>>b; sum=a+b; cout<< “Sum of two number is= “<<sum; } }; void main() { addition ob; ob. a= 10; ob. b=20; ob. add(); getch(); } Using Access Specifier in Class Public: Accessible both inside and outside the class Private: Accessible inside the class but not outside the class Protected: accessible inside the class and only in inherited classes //Error; a and b not accessible outside the class because they are declared private
  • 16. 3. INHERITANCE It is a mechanism in which one class acquires the property of another class. Derived Class (child) • The class that inherits from another class Base Class (Parent) • The class being inherited from
  • 18. Syntax: class base_class { //Body of base class }; class derived_class : access_specifier base_class { //Body of derived class }; Base Class Derived Class
  • 19. 4. Polymorphism Polymorphism means "one interface, multiple forms"
  • 20. class Animal { public: void animalSound() { cout << "The animal makes a sound n" ; } }; class Pig : public Animal { public: void animalSound() { cout << "The pig says: wee wee n" ; } }; class Dog : public Animal { public: void animalSound() { cout << "The dog says: bow wow n" ; } }; void main() { Animal myAnimal; Pig myPig; Dog myDog; myAnimal.animalSound(); myPig.animalSound(); myDog.animalSound(); } OUTPUT The animal makes a sound The pig says: wee wee The dog says: bow wow Base Class (Animal) Derived Class (Pig) Derived Class (Dog)
  • 21. class Animal { public: void animalSound() { cout << "The animal makes a sound n" ; } }; class Pig : public Animal { public: void animalSound() { cout << "The pig says: wee wee n" ; } }; class Dog : public Animal { public: void animalSound() { cout << "The dog says: bow wow n" ; } }; void main() { Animal myAnimal; Pig myPig; Dog myDog; myAnimal.animalSound(); myPig.animalSound(); myDog.animalSound(); } OUTPUT The animal makes a sound The pig says: wee wee The dog says: bow wow Base Class (Animal) Derived Class (Pig) Derived Class (Dog)