Object Oriented
Programming with C++
Concepts of
OOP
Concepts of OOP
• Introduction to OOP
• Procedural Vs. Object Oriented Programming
• Principles of OOP
• Benefits and applications of OOP
Introduction to OOP
OOP is a design philosophy. It stands for Object Oriented
Programming.
C++ was founded in (1983)
Bjarne Stroustrup
Introduction to OOP
Object-Oriented Programming (OOP) uses a different set of
programming languages than old procedural programming
languages like (C, Pascal, etc.).
Everything in OOP is grouped as self sustainable "objects".
What is Object?
Pen Board Laptop
Bench Student Projector
Physical objects…
What is Object?
Result Account
Bank Account
Logical objects…
Attributes and operations
Attributes: Attributes: Attributes:
Name Company AccountNo
Age Model HolderName
Weight Weight Balance
Operations: Operations: Operations:
Eat Drive Deposit
Sleep Stop Withdraw
Walk FillFuel Transfer
Write down 5 objects with its attributes and operations
What is Object ?
OBJECT: CAR
Events
Properties (Describe)
On_Start
Manufacturer
On_Parked
Model
On_Brake
Color
Year
Methods (Actions)
Price
Start
Drive
Park
Classes…
Class: Blueprint (template) for object.
Object: Instance of class.
Class
Applications of OOP
Real Time Systems Design
Simulation and Modeling System
Object Oriented Database
Client-Server System
Neural Networking and Parallel Programming
Decision Support and Office Automation Systems
CIM/CAD/CAM Systems
AI and Expert Systems
Procedural Vs. Object Oriented Programming
POP OOP
Emphasis is on doing things not on Emphasis is on data rather than
data, means it is function driven procedure, means object driven
Main focus is on the function and Main focus is on the data that is
procedures that operate on data being operated
Top Down approach in program Bottom Up approach in program
design design
Large programs are divided into Large programs are divided into
smaller programs known as classes and objects
functions
Most of the functions share global Data is tied together with function in
data the data structure
Procedural Vs. Object Oriented Programming
POP OOP
Data moves openly in the system Data is hidden and cannot be
from one function to another accessed by external functions
function
Adding of data and function is Adding of data and function is easy
difficult
We cannot declare namespace We can use name space directly,
directly Ex: using namespace std;
Concepts like inheritance, Concepts like inheritance,
polymorphism, data encapsulation, polymorphism, data encapsulation,
abstraction, access specifiers are not abstraction, access specifiers are
available. available and can be used easily
Examples: C, Fortran, Pascal, etc… Examples: C++, Java, C#, etc…
Principles of OOP (A.E.I.P)
There are mainly four OOP Principles
Abstraction
Encapsulation
Inheritance
Polymorphism
Abstraction
Abstraction refers to the act of representing essential features
without including the background details or explanations.
Abstraction provides you a generalized view of your classes or
object by providing relevant information.
Abstraction is the process of hiding the working style of an object,
and showing the information of an object in understandable
manner.
Abstraction Example
Abstract information (Necessary and
Common Information) for the object
“Mobile Phone” is make a call to any
number and can send SMS.”
Nokia 1400 Nokia 2700 Nokia 1400
Features: Features: Features:
FM Radio FM Radio
MP3 MP3
Camera Camera
Video Recording
Reading E-mails
Abstraction Example
Example:
If somebody in your collage tell you to fill application form, you
will fill your details like name, address, data of birth, which
semester, percentage you have got etc.
If some doctor gives you an application to fill the details, you
will fill the details like name, address, date of birth, blood group,
height and weight.
See in the above example what is the common thing?
Age, name, address so you can create the class which consist of
common thing that is called abstract class.
That class is not complete and it can inherit by other class.
Encapsulation
The wrapping up of data and functions into a single unit is known
as encapsulation
The insulation of the data from direct access by the program is
called data hiding or information hiding.
It is the process of enclosing one or more details from outside
world through access right.
Encapsulation
• Abstraction is a process where you show
only “relevant” data and “hide”
unnecessary details of an object from the
• Encapsulation is the process of combining
user.
data and functions into a single unit called
• Consider your mobile phone, you just
class. In Encapsulation, the data is not
need to know what buttons are to be
accessed directly; it is accessed through
pressed to send a message or make a call,
the functions present inside the class.
What happens when you press a button,
• Users are unaware about working of
how your messages are sent, how your
circuitry and hardware devices.
calls are connected is all abstracted away
from the user.
Abstraction Vs Encapsulation
Abstraction says what details to be made visible & Encapsulation
provides the level of access right to that visible details.
Example:
When we switch on the Bluetooth I am able to connect another
mobile but not able to access the other mobile features like
dialling a number, accessing inbox etc. This is because, Bluetooth
feature is given some level of abstraction.
Abstraction Vs Encapsulation
When mobile A is connected with mobile B via Bluetooth whereas
mobile B is already connected to mobile C then A is not allowed to
connect C via B. This is because of accessibility restriction.
A B
C
Inheritance
Inheritance is the process by which objects of one class acquire
the properties of objects of another class.
Vehicle
Land Water Air
Bus Car Ship Boat Aero plane Helicopter
Here Vehicle class can have properties like Chassis no. , Engine,
Colour etc.
All these properties inherited by sub classes of vehicle class.
Polymorphism
Polymorphism means ability to take more than one form.
For example the operation addition.
For two numbers the operation will generate a sum.
If the operands are strings, then the operation would produce a
third string by concatenation.
Thank You