[go: up one dir, main page]

0% found this document useful (0 votes)
12 views24 pages

Unit 1 Part 2 Notes

Uploaded by

Anuj Samdariya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views24 pages

Unit 1 Part 2 Notes

Uploaded by

Anuj Samdariya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 24

Object Oriented

Programming with C++

Concepts of
OOP
Concepts of OOP Weightage: 8%

• Introduction to OOP
• Procedural Vs. Object Oriented Programming
• Principles of OOP
• Benefits and applications of OOP

Concepts of OOP 2
Introduction to OOP
 OOP is a design philosophy. It stands for Object Oriented
Programming.
 C++ was founded in (1983)

Bjarne Stroustrup

Concepts of OOP 3
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".

Concepts of OOP 4
What is Object?

Pen Board Laptop

Bench Student Projector


Physical objects…
Concepts of OOP 5
What is Object?

Result Account

Bank Account
Logical objects…
Concepts of OOP 6
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

Concepts of OOP 7
What is Object ?
OBJECT: CAR

Events
Properties (Describe)
On_Start
Manufacturer
On_Parked
Model
On_Brake
Color
Year
Methods (Actions)
Price
Start
Drive
Park

Concepts of OOP 8
Classes…

Class: Blueprint (template) for object.


Object: Instance of class.

Concepts of OOP 9
Class

Concepts of OOP 10
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

Concepts of OOP 11
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

Concepts of OOP 12
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…

Concepts of OOP 13
Principles of OOP (A.E.I.P)
 There are mainly four OOP Principles

Abstraction

Encapsulation

Inheritance

Polymorphism

Concepts of OOP 14
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.

Concepts of OOP 15
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

Concepts of OOP 16
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.

Concepts of OOP 17
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.

Concepts of OOP 18
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.
Concepts of OOP 19
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.

Concepts of OOP 20
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

Concepts of OOP 21
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.

Concepts of OOP 22
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.

Concepts of OOP 23
Thank You

You might also like