SlideShare a Scribd company logo
Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 1
Haresh Jaiswal
Rising Technologies, Jalna.
Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 2
Object Oriented Concepts
 Objects
 Classes
 Data Abstraction
 Encapsulation
 Polymorphism
 Inheritance
Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 3
Object
 Objects are the basic run-time entities in an OOP
environment.
 They may represent:
 a person,
 a place,
 a bank account or
 any item that the program has to handle.
 Objects are simply variables of type class. Or In pure OOP
terms an object is an instance of a user defined data type
class.
Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 4
Object
 As the name object-oriented implies, objects are key to
understand object-oriented technology.
 You can look around you & can see many examples of
real-world objects:
 your cell phone,
 your dog,
 your television set,
 your car.
Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 5
Object
 All these real-world objects share two characteristics:
 they all have state
 and they all have behaviour
Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 6
Real-World Objects
 A Real World Object : Dog
 have state like
1. Name,
2. Colour,
3. Breed
 have behaviours like
1. Barking,
2. Eating
State Value
Name Tommy
Colour Brown
Breed Labrador
Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 7
Real-World Objects
 A Real World Object : Car
 have state like
1. Brand,
2. Make,
3. Engine CC
 have behaviours like
1. Accelerate,
2. Brake,
3. Change Gear State Value
Brand Maruti
Make Swift
Engine CC 1248 CC
Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 8
Programmatic Objects
 Software/Programmatic objects are modelled after real-
world objects in that they too have state and behaviour.
 A Programmatic object : Box
 have state like
 Height,
 Width,
 Depth
 have behaviours like
 getDimensions()
 putVolume()
Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 9
Programmatic Objects
 A Programmatic object : Bank Account
 have state like
 Acct No,
 Acct Holder’s Name,
 Current Balance
 have behaviours like
 Deposit(),
 Withdrawal()
Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 10
Programmatic Objects
 A Programmatic object : Employee
 have state like
 Employee ID,
 Employee Name,
 Basic Salary
 have behaviours like
 getData(),
 putSalary()
Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 11
Programmatic Objects
 Everything that the software object knows (its state) and
can do (its behaviour) is expressed by the variables and
methods within that object.
 A software/programmatic object maintains:
 its state in variables
 implements its behaviour with methods/functions.
Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 12
Programming Objects
Object : Student
State (Data)
RollNo
Name
M1, M2, M3
Behaviour (Functions)
getData()
putResult()
Object : Employee
State (Data)
EmpNo
Name
Basic, Ta, Da, Gross
Object : Box
State (Data)
Height
Width
Depth
Behaviour (Functions)
getDimensions()
putVolume()
Behaviour (Functions)
getData()
putSalary()
Each object contains Data and Code to manipulate that Data
Or
An object is a bundle of variables and related methods/functions.
Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 13
Example of Objects
 A software object that modelled your real-world box
would have variables that indicates the box’s current
state:
 Height : 4
 Width : 7
 Depth : 6
 The software object box would also have
methods/functions to:
 getDimensions() : to take dimensions as input from user
 putVolume() : to calculate and print volume of box
Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 14
Example of Objects
 A software object that modelled your real-world car
would have variables that indicates the car’s current
state:
 speed : 10 mph,
 pedal cadence : 90 rpm,
 current gear is : 5th.
 The software object car would also have
methods/functions to:
 brake,
 change the pedal cadence,
 change gears.
Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 15
Example of Objects
 You can think of an object as a fancy variable;
 it stores data and you can “make requests” to that object,
asking it to perform operations on itself.
Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 16
Example of Objects
 You can represent real-world objects using software
objects. You can represent:
 real-world dog as software object in an animation program.
 real-world car as a software object within a game program.
Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 17
Class
 Classes are actually special kinds of templates from which
you can create objects.
 Definition : Class is a way of binding Data and its
associated Functions/Methods together.
 When you define a class, you define a blueprint for an
abstract data type.
Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 18
Class
 A class is created to characterise your programmatic
object.
 Everything a programmatic object knows (its state) and
can do (its behaviour) is characterised using variables and
methods defined inside the class.
 A class is a logical abstract but an object has a physical
existence in the memory.
Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 19
Abstract Data Type
 Defining a Class means creating an abstract data type in
any object oriented programming language.
 A data type can be called abstract, if it do not reveal its
internal implementation to the user of that type.
Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 20
Abstract Data Type
 There are 2 parts to each ADT:
 The external (public) part, which consists of:
 the conceptual picture (user's view of how the object looks like)
 the conceptual operations (what the user can do to the ADT)
 The internal (private) part, which consists of:
 the representation (how the structure is actually stored)
 the implementation of the operations (the actual code)
Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 21
Abstraction
 In simple words, abstraction is ‘Hiding implementation
details behind the interface’
 When abstraction is created our concern is limited to
what it can do rather how it is doing it.
Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 22
Abstraction
 When we drive a car we often need to change the gears
of the vehicle but we are not concerned about the inner
details of the vehicle engine. What matters to us is that
we must shift a gear, that's it. This is abstraction
 Show only those details which matters to the user.
Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 23
Abstraction
 What exactly is Hiding implementation details behind the
interface?
Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 24
Abstraction
class box
{
private:
float h, w, d;
public:
void getDimensions()
{
cout << “Enter Height, Width & Depth : “;
cin >> h >> w >> d;
}
void putVolume()
{
cout << “Volume : “ << (h * w * d);
}
};
Class Definition, the internal details/implementation of ADT
Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 25
Abstraction
Object : Box
State(Data)
Height
Width
Depth
Behaviour/Functions
getDimensions()
putVolume()
An Object of Class Box, user has knowledge about its external
interface only.
Actual implementation,
User has no knowledge
about this part of object.
External Interface to use
this object,
User has knowledge only
about this part of the object.
Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 26
Encapsulation
 The wrapping of code and data into a single unit is called
as encapsulation.
 Encapsulation binds together data and code to
manipulate that data, it keeps both them safe from
outside interference and mis-use.
 Encapsulation is a protective container that prevents code
and data from being accessed by other code defined
outside the container.
 Creating a Class is the way to implement Encapsulation.
Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 27
Encapsulation
 Object encapsulates data and operations in one unit
 An object is a bundle of data; who know how to do things
to itself.
Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 28
Polymorphism
 In object-oriented programming polymorphism means
the ability to appear in many forms.
 polymorphism refers to a programming language's ability
to process objects differently depending on their data
type or class.
 It is the provision of a single interface to entities of
different types.
Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 29
Polymorphism
 An operation may perform different behaviors in different
instances and the behavior depends upon the type of
data used in the operation.
Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 30
Polymorphism
 Consider the operation of adding two integer values using
+ operator, then the operation will generate a sum, but if
operands in the operation is of string type then the
operation would produce a third string by concatenation.
5 + 2 => 7 // integer operands
“Rising” + “Tech” => “Rising Tech” // string operands
Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 31
Polymorphism
 So this process of making an operator to perform
different behaviors in different instances is known as
“operator overloading”
Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 32
Polymorphism
Class : Shape
---------------------------
Draw()
Object : Circle
---------------------
Draw(circle)
Object : Box
---------------------
Draw(box)
Object : Triangle
---------------------
Draw(triangle)
This figure illustrates that a single function name can be used to handle
different number and different type of arguments.
Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 33
Polymorphism
 Using a single function name to perform different types of
tasks is known as ‘Function Overloading’
 This is something similar to a particular word having
several different meanings depending on the context.
I Saw a Saw with a Saw Sawing a Saw...
Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 34
Virtual Functions
 Virtual functions is the ability to redefine methods in
derived classes.
 For example, given a base class shape, polymorphism
enables the programmer to define different area
methods for any number of derived classes, such as
circles, rectangles and triangles.
 No matter what shape an object is, applying
the area method to it will return the correct results.
Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 35
Polymorphism
Polymorphism
Compile Time
Function
Overloading
Operator
Overloading
Runtime
Virtual
Functions
Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 36
Polymorphism
 Polymorphism plays an important role in allowing objects
to have different internal structures but to share the
same external interface.

More Related Content

What's hot (20)

PPT
Inheritance and Polymorphism
BG Java EE Course
 
PPT
Disk scheduling algorithms
Paresh Parmar
 
PPTX
Boolean algebra
Debarati Das
 
PPTX
Presentation on-exception-handling
Nahian Ahmed
 
PPTX
C dynamic ppt
RJ Mehul Gadhiya
 
PPT
Deadlock Detection
Stuart Joy
 
PPTX
data structures and algorithms Unit 3
infanciaj
 
PDF
flip flop Presentation
maalik123
 
PPTX
07. Virtual Functions
Haresh Jaiswal
 
PPTX
Timing Diagram.pptx
ISMT College
 
PDF
Shared-Memory Multiprocessors
Salvatore La Bua
 
PPTX
Pointers, virtual function and polymorphism
lalithambiga kamaraj
 
PDF
Unit - 2.pdf
AravindAnand21
 
PPTX
AutoBoxing and Unboxing in java ppt.pptx
AnjankumarSharma1
 
PPTX
System bus timing 8086
mpsrekha83
 
PPT
Interfacing of io device to 8085
Nitin Ahire
 
PPT
Pin Description Of Intel 80386 DX Microprocessor
Raunaq Sahni
 
PPT
Chapter 12 ds
Hanif Durad
 
PPTX
Latches &amp; flip flop
Nousheen Arshad
 
Inheritance and Polymorphism
BG Java EE Course
 
Disk scheduling algorithms
Paresh Parmar
 
Boolean algebra
Debarati Das
 
Presentation on-exception-handling
Nahian Ahmed
 
C dynamic ppt
RJ Mehul Gadhiya
 
Deadlock Detection
Stuart Joy
 
data structures and algorithms Unit 3
infanciaj
 
flip flop Presentation
maalik123
 
07. Virtual Functions
Haresh Jaiswal
 
Timing Diagram.pptx
ISMT College
 
Shared-Memory Multiprocessors
Salvatore La Bua
 
Pointers, virtual function and polymorphism
lalithambiga kamaraj
 
Unit - 2.pdf
AravindAnand21
 
AutoBoxing and Unboxing in java ppt.pptx
AnjankumarSharma1
 
System bus timing 8086
mpsrekha83
 
Interfacing of io device to 8085
Nitin Ahire
 
Pin Description Of Intel 80386 DX Microprocessor
Raunaq Sahni
 
Chapter 12 ds
Hanif Durad
 
Latches &amp; flip flop
Nousheen Arshad
 

Viewers also liked (20)

PDF
01. introduction to C++
Haresh Jaiswal
 
PPTX
General oops concepts
nidhiyagnik123
 
PDF
04. constructor & destructor
Haresh Jaiswal
 
PPT
Oops
Prabhu R
 
PPTX
Parameterized Constructor
Mukesh Pathak
 
PDF
OOP Basic
Yeti Sno
 
PPT
SystemVerilog OOP Ovm Features Summary
Amal Khailtash
 
PPTX
Constructor and destructor
Shubham Vishwambhar
 
PDF
Oop basic overview
Deborah Akuoko
 
PPTX
Oop concepts
Melick Baranasooriya
 
PPTX
constructor & destructor in cpp
gourav kottawar
 
PPT
General OOP concept [by-Digvijay]
Digvijay Singh Karakoti
 
PPTX
Object Orinted Programing(OOP) concepts \
Pritom Chaki
 
PPTX
Constructors & destructors
ForwardBlog Enewzletter
 
PPT
Basic concepts of object oriented programming
Sachin Sharma
 
PPT
Object-oriented concepts
BG Java EE Course
 
PPTX
Introduction to Object Oriented Programming
Moutaz Haddara
 
PPTX
Constructor and destructor in c++
Learn By Watch
 
PPTX
Constructor ppt
Vinod Kumar
 
PPT
Object Oriented Programming Concepts
thinkphp
 
01. introduction to C++
Haresh Jaiswal
 
General oops concepts
nidhiyagnik123
 
04. constructor & destructor
Haresh Jaiswal
 
Oops
Prabhu R
 
Parameterized Constructor
Mukesh Pathak
 
OOP Basic
Yeti Sno
 
SystemVerilog OOP Ovm Features Summary
Amal Khailtash
 
Constructor and destructor
Shubham Vishwambhar
 
Oop basic overview
Deborah Akuoko
 
Oop concepts
Melick Baranasooriya
 
constructor & destructor in cpp
gourav kottawar
 
General OOP concept [by-Digvijay]
Digvijay Singh Karakoti
 
Object Orinted Programing(OOP) concepts \
Pritom Chaki
 
Constructors & destructors
ForwardBlog Enewzletter
 
Basic concepts of object oriented programming
Sachin Sharma
 
Object-oriented concepts
BG Java EE Course
 
Introduction to Object Oriented Programming
Moutaz Haddara
 
Constructor and destructor in c++
Learn By Watch
 
Constructor ppt
Vinod Kumar
 
Object Oriented Programming Concepts
thinkphp
 
Ad

Similar to 03. oop concepts (20)

PPT
Chapter 02 The Object Model_Software E.ppt
AhammadUllah3
 
PPTX
4-OOPS.pptx
SatyamMishra237306
 
PDF
Bt8901 objective oriented systems1
Techglyphs
 
PPT
Oop rosenschein
Himanshu Modi
 
PPT
Oops Concepts
guest1aac43
 
PPTX
Std 12 computer chapter 6 object oriented concepts (part 1)
Nuzhat Memon
 
PPT
uml123 copy
Amit Sachan
 
DOCX
Ooad notes
NancyJP
 
PPTX
COMP111-Week-1_138439.pptx
FarooqTariq8
 
PPTX
General oop concept
Avneesh Yadav
 
PPTX
Bab satu
Aida Ramlan II
 
PDF
babsatu-140703233001-phpapp666666601.pdf
kashafishfaq21
 
PDF
Programming Laboratory Unit 1.pdf
swapnilslide2019
 
PPTX
the Concept of Object-Oriented Programming
Aida Ramlan II
 
PPTX
Cs690 object oriented_software_engineering_team01_ report
Khushboo Wadhwani
 
PPTX
Modeling- Object, Dynamic and Functional
Rajani Bhandari
 
PPT
Object oriented concepts
christradus
 
PPTX
All in 1
Umer Tanvir
 
PDF
Aggregates, Entities and Value objects - Devnology 2010 community day
Rick van der Arend
 
Chapter 02 The Object Model_Software E.ppt
AhammadUllah3
 
4-OOPS.pptx
SatyamMishra237306
 
Bt8901 objective oriented systems1
Techglyphs
 
Oop rosenschein
Himanshu Modi
 
Oops Concepts
guest1aac43
 
Std 12 computer chapter 6 object oriented concepts (part 1)
Nuzhat Memon
 
uml123 copy
Amit Sachan
 
Ooad notes
NancyJP
 
COMP111-Week-1_138439.pptx
FarooqTariq8
 
General oop concept
Avneesh Yadav
 
Bab satu
Aida Ramlan II
 
babsatu-140703233001-phpapp666666601.pdf
kashafishfaq21
 
Programming Laboratory Unit 1.pdf
swapnilslide2019
 
the Concept of Object-Oriented Programming
Aida Ramlan II
 
Cs690 object oriented_software_engineering_team01_ report
Khushboo Wadhwani
 
Modeling- Object, Dynamic and Functional
Rajani Bhandari
 
Object oriented concepts
christradus
 
All in 1
Umer Tanvir
 
Aggregates, Entities and Value objects - Devnology 2010 community day
Rick van der Arend
 
Ad

Recently uploaded (20)

PPTX
The Human Eye and The Colourful World Class 10 NCERT Science.pptx
renutripathibharat
 
PPTX
Explorando Recursos do Summer '25: Dicas Essenciais - 02
Mauricio Alexandre Silva
 
PPTX
classroom based quiz bee.pptx...................
ferdinandsanbuenaven
 
PPTX
How to Configure Prepayments in Odoo 18 Sales
Celine George
 
PPTX
HEAD INJURY IN CHILDREN: NURSING MANAGEMENGT.pptx
PRADEEP ABOTHU
 
PPTX
Modern analytical techniques used to characterize organic compounds. Birbhum ...
AyanHossain
 
PDF
IMP NAAC REFORMS 2024 - 10 Attributes.pdf
BHARTIWADEKAR
 
PPTX
ANORECTAL MALFORMATIONS: NURSING MANAGEMENT.pptx
PRADEEP ABOTHU
 
PPTX
Pyhton with Mysql to perform CRUD operations.pptx
Ramakrishna Reddy Bijjam
 
PPTX
Nutri-QUIZ-Bee-Elementary.pptx...................
ferdinandsanbuenaven
 
PPTX
Maternal and Child Tracking system & RCH portal
Ms Usha Vadhel
 
PPTX
How to Manage Promotions in Odoo 18 Sales
Celine George
 
PDF
Zoology (Animal Physiology) practical Manual
raviralanaresh2
 
PPTX
ROLE OF ANTIOXIDANT IN EYE HEALTH MANAGEMENT.pptx
Subham Panja
 
PPSX
Health Planning in india - Unit 03 - CHN 2 - GNM 3RD YEAR.ppsx
Priyanshu Anand
 
PPTX
How to Manage Access Rights & User Types in Odoo 18
Celine George
 
PPTX
ASRB NET 2023 PREVIOUS YEAR QUESTION PAPER GENETICS AND PLANT BREEDING BY SAT...
Krashi Coaching
 
PPTX
nutriquiz grade 4.pptx...............................................
ferdinandsanbuenaven
 
PPTX
LEGAL ASPECTS OF PSYCHIATRUC NURSING.pptx
PoojaSen20
 
PDF
CONCURSO DE POESIA “POETUFAS – PASSOS SUAVES PELO VERSO.pdf
Colégio Santa Teresinha
 
The Human Eye and The Colourful World Class 10 NCERT Science.pptx
renutripathibharat
 
Explorando Recursos do Summer '25: Dicas Essenciais - 02
Mauricio Alexandre Silva
 
classroom based quiz bee.pptx...................
ferdinandsanbuenaven
 
How to Configure Prepayments in Odoo 18 Sales
Celine George
 
HEAD INJURY IN CHILDREN: NURSING MANAGEMENGT.pptx
PRADEEP ABOTHU
 
Modern analytical techniques used to characterize organic compounds. Birbhum ...
AyanHossain
 
IMP NAAC REFORMS 2024 - 10 Attributes.pdf
BHARTIWADEKAR
 
ANORECTAL MALFORMATIONS: NURSING MANAGEMENT.pptx
PRADEEP ABOTHU
 
Pyhton with Mysql to perform CRUD operations.pptx
Ramakrishna Reddy Bijjam
 
Nutri-QUIZ-Bee-Elementary.pptx...................
ferdinandsanbuenaven
 
Maternal and Child Tracking system & RCH portal
Ms Usha Vadhel
 
How to Manage Promotions in Odoo 18 Sales
Celine George
 
Zoology (Animal Physiology) practical Manual
raviralanaresh2
 
ROLE OF ANTIOXIDANT IN EYE HEALTH MANAGEMENT.pptx
Subham Panja
 
Health Planning in india - Unit 03 - CHN 2 - GNM 3RD YEAR.ppsx
Priyanshu Anand
 
How to Manage Access Rights & User Types in Odoo 18
Celine George
 
ASRB NET 2023 PREVIOUS YEAR QUESTION PAPER GENETICS AND PLANT BREEDING BY SAT...
Krashi Coaching
 
nutriquiz grade 4.pptx...............................................
ferdinandsanbuenaven
 
LEGAL ASPECTS OF PSYCHIATRUC NURSING.pptx
PoojaSen20
 
CONCURSO DE POESIA “POETUFAS – PASSOS SUAVES PELO VERSO.pdf
Colégio Santa Teresinha
 

03. oop concepts

  • 1. Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 1 Haresh Jaiswal Rising Technologies, Jalna.
  • 2. Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 2 Object Oriented Concepts  Objects  Classes  Data Abstraction  Encapsulation  Polymorphism  Inheritance
  • 3. Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 3 Object  Objects are the basic run-time entities in an OOP environment.  They may represent:  a person,  a place,  a bank account or  any item that the program has to handle.  Objects are simply variables of type class. Or In pure OOP terms an object is an instance of a user defined data type class.
  • 4. Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 4 Object  As the name object-oriented implies, objects are key to understand object-oriented technology.  You can look around you & can see many examples of real-world objects:  your cell phone,  your dog,  your television set,  your car.
  • 5. Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 5 Object  All these real-world objects share two characteristics:  they all have state  and they all have behaviour
  • 6. Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 6 Real-World Objects  A Real World Object : Dog  have state like 1. Name, 2. Colour, 3. Breed  have behaviours like 1. Barking, 2. Eating State Value Name Tommy Colour Brown Breed Labrador
  • 7. Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 7 Real-World Objects  A Real World Object : Car  have state like 1. Brand, 2. Make, 3. Engine CC  have behaviours like 1. Accelerate, 2. Brake, 3. Change Gear State Value Brand Maruti Make Swift Engine CC 1248 CC
  • 8. Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 8 Programmatic Objects  Software/Programmatic objects are modelled after real- world objects in that they too have state and behaviour.  A Programmatic object : Box  have state like  Height,  Width,  Depth  have behaviours like  getDimensions()  putVolume()
  • 9. Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 9 Programmatic Objects  A Programmatic object : Bank Account  have state like  Acct No,  Acct Holder’s Name,  Current Balance  have behaviours like  Deposit(),  Withdrawal()
  • 10. Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 10 Programmatic Objects  A Programmatic object : Employee  have state like  Employee ID,  Employee Name,  Basic Salary  have behaviours like  getData(),  putSalary()
  • 11. Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 11 Programmatic Objects  Everything that the software object knows (its state) and can do (its behaviour) is expressed by the variables and methods within that object.  A software/programmatic object maintains:  its state in variables  implements its behaviour with methods/functions.
  • 12. Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 12 Programming Objects Object : Student State (Data) RollNo Name M1, M2, M3 Behaviour (Functions) getData() putResult() Object : Employee State (Data) EmpNo Name Basic, Ta, Da, Gross Object : Box State (Data) Height Width Depth Behaviour (Functions) getDimensions() putVolume() Behaviour (Functions) getData() putSalary() Each object contains Data and Code to manipulate that Data Or An object is a bundle of variables and related methods/functions.
  • 13. Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 13 Example of Objects  A software object that modelled your real-world box would have variables that indicates the box’s current state:  Height : 4  Width : 7  Depth : 6  The software object box would also have methods/functions to:  getDimensions() : to take dimensions as input from user  putVolume() : to calculate and print volume of box
  • 14. Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 14 Example of Objects  A software object that modelled your real-world car would have variables that indicates the car’s current state:  speed : 10 mph,  pedal cadence : 90 rpm,  current gear is : 5th.  The software object car would also have methods/functions to:  brake,  change the pedal cadence,  change gears.
  • 15. Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 15 Example of Objects  You can think of an object as a fancy variable;  it stores data and you can “make requests” to that object, asking it to perform operations on itself.
  • 16. Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 16 Example of Objects  You can represent real-world objects using software objects. You can represent:  real-world dog as software object in an animation program.  real-world car as a software object within a game program.
  • 17. Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 17 Class  Classes are actually special kinds of templates from which you can create objects.  Definition : Class is a way of binding Data and its associated Functions/Methods together.  When you define a class, you define a blueprint for an abstract data type.
  • 18. Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 18 Class  A class is created to characterise your programmatic object.  Everything a programmatic object knows (its state) and can do (its behaviour) is characterised using variables and methods defined inside the class.  A class is a logical abstract but an object has a physical existence in the memory.
  • 19. Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 19 Abstract Data Type  Defining a Class means creating an abstract data type in any object oriented programming language.  A data type can be called abstract, if it do not reveal its internal implementation to the user of that type.
  • 20. Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 20 Abstract Data Type  There are 2 parts to each ADT:  The external (public) part, which consists of:  the conceptual picture (user's view of how the object looks like)  the conceptual operations (what the user can do to the ADT)  The internal (private) part, which consists of:  the representation (how the structure is actually stored)  the implementation of the operations (the actual code)
  • 21. Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 21 Abstraction  In simple words, abstraction is ‘Hiding implementation details behind the interface’  When abstraction is created our concern is limited to what it can do rather how it is doing it.
  • 22. Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 22 Abstraction  When we drive a car we often need to change the gears of the vehicle but we are not concerned about the inner details of the vehicle engine. What matters to us is that we must shift a gear, that's it. This is abstraction  Show only those details which matters to the user.
  • 23. Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 23 Abstraction  What exactly is Hiding implementation details behind the interface?
  • 24. Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 24 Abstraction class box { private: float h, w, d; public: void getDimensions() { cout << “Enter Height, Width & Depth : “; cin >> h >> w >> d; } void putVolume() { cout << “Volume : “ << (h * w * d); } }; Class Definition, the internal details/implementation of ADT
  • 25. Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 25 Abstraction Object : Box State(Data) Height Width Depth Behaviour/Functions getDimensions() putVolume() An Object of Class Box, user has knowledge about its external interface only. Actual implementation, User has no knowledge about this part of object. External Interface to use this object, User has knowledge only about this part of the object.
  • 26. Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 26 Encapsulation  The wrapping of code and data into a single unit is called as encapsulation.  Encapsulation binds together data and code to manipulate that data, it keeps both them safe from outside interference and mis-use.  Encapsulation is a protective container that prevents code and data from being accessed by other code defined outside the container.  Creating a Class is the way to implement Encapsulation.
  • 27. Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 27 Encapsulation  Object encapsulates data and operations in one unit  An object is a bundle of data; who know how to do things to itself.
  • 28. Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 28 Polymorphism  In object-oriented programming polymorphism means the ability to appear in many forms.  polymorphism refers to a programming language's ability to process objects differently depending on their data type or class.  It is the provision of a single interface to entities of different types.
  • 29. Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 29 Polymorphism  An operation may perform different behaviors in different instances and the behavior depends upon the type of data used in the operation.
  • 30. Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 30 Polymorphism  Consider the operation of adding two integer values using + operator, then the operation will generate a sum, but if operands in the operation is of string type then the operation would produce a third string by concatenation. 5 + 2 => 7 // integer operands “Rising” + “Tech” => “Rising Tech” // string operands
  • 31. Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 31 Polymorphism  So this process of making an operator to perform different behaviors in different instances is known as “operator overloading”
  • 32. Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 32 Polymorphism Class : Shape --------------------------- Draw() Object : Circle --------------------- Draw(circle) Object : Box --------------------- Draw(box) Object : Triangle --------------------- Draw(triangle) This figure illustrates that a single function name can be used to handle different number and different type of arguments.
  • 33. Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 33 Polymorphism  Using a single function name to perform different types of tasks is known as ‘Function Overloading’  This is something similar to a particular word having several different meanings depending on the context. I Saw a Saw with a Saw Sawing a Saw...
  • 34. Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 34 Virtual Functions  Virtual functions is the ability to redefine methods in derived classes.  For example, given a base class shape, polymorphism enables the programmer to define different area methods for any number of derived classes, such as circles, rectangles and triangles.  No matter what shape an object is, applying the area method to it will return the correct results.
  • 35. Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 35 Polymorphism Polymorphism Compile Time Function Overloading Operator Overloading Runtime Virtual Functions
  • 36. Rising Technologies, Jalna (MH). + 91 9423156065, http://www.RisingTechnologies.in 36 Polymorphism  Polymorphism plays an important role in allowing objects to have different internal structures but to share the same external interface.