0% found this document useful (0 votes)
4 views17 pages

Unit 1 Session 1

The document outlines the principles of Object Oriented Programming (OOP) in C++, contrasting it with Procedure-Oriented Programming. It covers key concepts such as classes, objects, inheritance, polymorphism, dynamic binding, and message passing, emphasizing the importance of data encapsulation and the modular approach in program design. The document highlights the advantages of OOP, including data protection and the ability to model real-world problems more effectively.

Uploaded by

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

Unit 1 Session 1

The document outlines the principles of Object Oriented Programming (OOP) in C++, contrasting it with Procedure-Oriented Programming. It covers key concepts such as classes, objects, inheritance, polymorphism, dynamic binding, and message passing, emphasizing the importance of data encapsulation and the modular approach in program design. The document highlights the advantages of OOP, including data protection and the ability to model real-world problems more effectively.

Uploaded by

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

PROGRAMMING

IN
C++
Juhi Kaneria
Lecturer in Computer Engineering Department
R. C. Technical Institute
UNIT-1
Principles of Object
Oriented Programming
Major Learning Outcomes

Differentiate procedure and object oriented


languages
1

Explain the basic concepts of C++ Language


2
Procedure-Oriented Programming
 The problem is viewed as the sequence of things to be done such
as reading, calculating, printing, etc
 Program is divided into small parts called functions
 Ex: Cobol, Fortran and C

MAIN
PROGRAM

FUNCTION-1 FUNCTION-2 FUNCTION-3

FUNCTION-4 FUNCTION-5

FUNCTION-6 FUNCTION-7 FUNCTION-8


Characteristics of Procedure-
oriented programming
 Emphasis is on doing things (algorithms)
 Large programs are divided into smaller programs known as functions
 Most of the functions share global data
 Data move openly around the system from function to function
 Functions transform data from one form to another
 Employs top-down approach in program design
Drawbacks of Procedure-oriented
programming
 Global data are more vulnerable to an inadvertent change by a
function. In case we need to revise an external data structure, we
also need to revise all functions that access the data. This provides
an opportunity for bugs to creep in
 Real world problems can not be modelled very well because functions
are action-oriented and do not really correspond to the element of the
problem
 Solution: Object Oriented Paradigm
Object Oriented Paradigm
 Allows decomposition of a problem into a number of entities called
objects
 Each object has data and function associated with it
 Design and development of program using modular approach
 Does not allow data to flow freely around the system
 Ties data more closely to the function that operate on it, and protects
it from accidental modification from outside function
 Data of an object can be accessed only by the function associated
with it Object A Object B
 Function of one objectDATA
can access the function of other
DATA objects
Communicati
 FUNCTION FUNCTION
Ex: C++, Java on

Object C
DATA

FUNCTION
Features of object oriented
programming
 Emphasis is on data rather than procedure
 Programs are divided into what are known as objects
 Data structures are designed such that they characterize the objects
 Functions that operate on the data of an object are tied together in
the data structure
 Data is hidden and cannot be accessed by external function
 Objects may communicate with each other through function
 New data and functions can be easily added whenever necessary
 Follows bottom up approach in program design
Basic Concepts of Object Oriented
Programming
 Classes
 Objects
 Data abstraction and encapsulation
 Inheritance
 Polymorphism
 Dynamic binding
 Message passing
Objects
 Collection of data members and member functions
 Instance of class
 May represent a person, a place, a bank account, a table of data or any item
that the program has to handle
 Programming Objects be chosen to match closely with the real-world objects
 Each object has unique name and occupy space in the memory
 Ex: Orange, Grapes, Mango are the objects of class Fruits
OBJECT: STUDENT
DATA
Enrollment No.

Name
Date-of-birth
Marks
FUNCTIONS
Total
Average
Display
Classes
 User-defined data type that behave like built-in types of programming
language
 Set of data and code(function) of an object can be made a user-
defined datatype with the help of class.
 Objects are instance of the type class.
 Ex: Fruits Mango; (similar to int a; )
 Collection of objects similar type
Data Abstraction and Encapsulation
 Wrapping up of data and function into a single unit (called class) is
known as encapsulation
 Data is not accessible to the outside world, and only those functions
which are wrapped in the class can access it
 Insulation of the data from direct access by the program is called
data hiding or information hiding or data abstraction
 Representing essential features without including the background
details or explanation
Inheritance
 Process by which objects of one class acquired the properties of
objects of another classes
 Hierarchical classification
 Existing class is known as super class or base class
 New class is known as sub class or derived class
 Provides reusability
Birds
Attributes

Flying Birds Non-Flying


Attributes Birds
Attributes

Robin Swallow Penguin Kiwi


Attributes Attributes Attributes Attributes
Polymorphism
 Polymorphism, a Greek term, means the ability to take more than one
form
 An operation may exhibit different behaviour in different instances
 The behaviour depends upon the types of data used in the operation
 Ex: Operation of addition
 For two numbers: generate a sum
 For two strings: produce a third string by concatenation
 Extensively used in implementing inheritance
Dynamic Binding
 Binding refers to the linking of a procedure call to the code to be
executed in response to the call
 Code associated with a given procedure call is not known until the
time of the call at run time
 Consider the procedure “draw”
 Every object like triangle, circle, square etc. will have this procedure
 Its algorithm is unique to each object and so the draw procedure will be
redefined in each class that defines the object.
 At run-time, the code matching the object under current reference will be
called.
Shape
Draw()

Circle Square
Draw() Draw()
Message Passing
 An object-oriented program consists of a set of objects that
communicate with each other
 Process of programming in an OOP:
 Creating classes that define object and their behaviour
 Creating objects from class definitions
 Establishing communication among objects.
 Objects communicate with one another by sending and receiving
information much the same way as people pass messages to one
another.
THANK YOU!

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy