Introduction to C++….
Procedure oriented programming:
A typical program that consists of a list of instructions to
accomplish a task.
Larger programs are divided into a number of functions, where
each function has a well defined purpose.
Global data is accessible to all the functions it is difficult to find
out which data is being used by which function. Changes made can
affect in any manner.
Global Variables
Local Variables
Function A
Local Variables
Function B
Some important features of a procedure oriented programming
language:
1. Emphasis is laid on algorithm.
2. Complex programs are divided into functions.
3. Generally functions share important data.
4. Data is passed from function to function.
5. Top down approach is used in program design.
Drawback is that complexity increases as program grows larger.
Object Oriented Programming:
OOP does not allow data to move freely between the functions.
It binds the data to the function that operate on it and protects it
from being modified accidentally by outside functions.
The object oriented approach is to combine both data and the
functions that operate on that data, into a single unit called an
object.
Object 1
Object 2 Object 3
Member Functions
Data
Member Functions
Data
Member Functions
Data
Features of object oriented programming language:
1. Emphasis is laid on data.
2. Programs are divided into objects.
3. Objects contain the data and the functions that operate on the
data.
4. Data is hidden and cannot be accessed by outside functions.
5. Objects are allowed to communicate with each other through
functions.
6. Bottom Up approach is used in program design.
Drawback is that complexity increases as program grows larger.
Basic concepts used in object oriented programming:
1. Object 2. Class 3. Data Abstraction 4. Data Encapsulation
5. Inheritance 6. Reusability 7. Polymorphism 8. Dynamic binding
9. Message communication
1. Objects: Objects are entities that exhibit both state and behavior.
Objects are basic runtime entities.
Each object consists of data and code to manipulate the data.
Employee
Object: Employee
Data: Name, basic_pay
Functions: Read_data,
Net_pay, Display
Employee data
--------------------
Read_data
Net_pay
Display
Basic features of an object:
1. Objects are basic runtime entities. The word instance is a
synonym for object.
2. They represent a person, place or any data items that the
program has to handle.
3. They occupy space in memory with an associated address.
4. Objects communicate with each other by sending messages to
one another.
2. Class: A class is a collection of similar type of objects.
Object is an instance of a class.
A class is created with data members and the member functions.
Ex: Consider a class called shape, objects of this class would be
circle, rectangle, triangle etc.
object is created in this manner:
class name object name;
ex: shape ob1; Here shape is class and ob1 is object.
3. Data Abstraction: Data abstraction helps in binding data and
the functions together. The process of representing the essential
features without the background details is called abstraction.
4. Data Encapsulation: It binds both data and functions into a
class and keeps them safe from outside functions and misuse.
The data is accessible only through the functions, otherwise it
remains hidden from users.
This insulation of data from direct access by the program is called
data hiding or information hiding.
5. Inheritance: It is a process by which an object inherits the
properties of another object belonging to another class.
Ex: ‘mango’ is part of the class fruit which again is part of the
larger class food.
The original class is known as base class and the new class is
referred to as derived class or sub class.
6. Reusability: Once a class is created and tested and read to use,
it can be distributed to other programmers for using in their
programs, this is known as reusability.
Inheritance supports the idea of reusability, where the
programmers can add new features without modifying the existing
class.
7. Polymorphism: The ability to take more than one form is called
polymorphism.
Ex: All brands of air conditioners do the same work, cooling the
temperature.
Ex: Addition operator + is used to add two values and even it is
used to concatenate two strings.
This process of an operator acquiring different behavior in
different instances is known as operator overloading.
8. Dynamic binding:
Binding refers to the process of resolving the function to be
associated with the function call. There are two types…
1. Static binding: Binding takes place during compilation. It is also
known as early binding.
2. Dynamic binding: It is also called as late binding, coz the code
associated with a given function call is not known until run-time.
9. Message communication: A message is nothing but execution
of a procedure.
Message communication involves specifying the name of the
object, name of the function and the information to be sent.
For Ex: consider a class called stack.
stack1.push(1); here stack1 is object, push is a function
and 1 is information.
Applications of OOP
1. Real-time systems.
2. Object oriented database.
3. Artificial intelligence and expert systems.
4. Simulation and modeling.
5. Neural networks.
6. Office automation systems.
Difference between POP and OOP
Procedure Oriented Object oriented
Focus is on functions Focus is on data
Data is not secured Data is secure.
Uses top down programming
design
Uses bottom up programming
design
Does not model real world
problem
Models real world problems
Programs are divided into
functions
Programs are divided into
objects

Ch 1 Introduction to Object Oriented Programming.pptx

  • 1.
    Introduction to C++…. Procedureoriented programming: A typical program that consists of a list of instructions to accomplish a task. Larger programs are divided into a number of functions, where each function has a well defined purpose. Global data is accessible to all the functions it is difficult to find out which data is being used by which function. Changes made can affect in any manner. Global Variables Local Variables Function A Local Variables Function B
  • 2.
    Some important featuresof a procedure oriented programming language: 1. Emphasis is laid on algorithm. 2. Complex programs are divided into functions. 3. Generally functions share important data. 4. Data is passed from function to function. 5. Top down approach is used in program design. Drawback is that complexity increases as program grows larger.
  • 3.
    Object Oriented Programming: OOPdoes not allow data to move freely between the functions. It binds the data to the function that operate on it and protects it from being modified accidentally by outside functions. The object oriented approach is to combine both data and the functions that operate on that data, into a single unit called an object. Object 1 Object 2 Object 3 Member Functions Data Member Functions Data Member Functions Data
  • 4.
    Features of objectoriented programming language: 1. Emphasis is laid on data. 2. Programs are divided into objects. 3. Objects contain the data and the functions that operate on the data. 4. Data is hidden and cannot be accessed by outside functions. 5. Objects are allowed to communicate with each other through functions. 6. Bottom Up approach is used in program design. Drawback is that complexity increases as program grows larger.
  • 5.
    Basic concepts usedin object oriented programming: 1. Object 2. Class 3. Data Abstraction 4. Data Encapsulation 5. Inheritance 6. Reusability 7. Polymorphism 8. Dynamic binding 9. Message communication 1. Objects: Objects are entities that exhibit both state and behavior. Objects are basic runtime entities. Each object consists of data and code to manipulate the data. Employee Object: Employee Data: Name, basic_pay Functions: Read_data, Net_pay, Display Employee data -------------------- Read_data Net_pay Display
  • 6.
    Basic features ofan object: 1. Objects are basic runtime entities. The word instance is a synonym for object. 2. They represent a person, place or any data items that the program has to handle. 3. They occupy space in memory with an associated address. 4. Objects communicate with each other by sending messages to one another.
  • 7.
    2. Class: Aclass is a collection of similar type of objects. Object is an instance of a class. A class is created with data members and the member functions. Ex: Consider a class called shape, objects of this class would be circle, rectangle, triangle etc. object is created in this manner: class name object name; ex: shape ob1; Here shape is class and ob1 is object. 3. Data Abstraction: Data abstraction helps in binding data and the functions together. The process of representing the essential features without the background details is called abstraction.
  • 8.
    4. Data Encapsulation:It binds both data and functions into a class and keeps them safe from outside functions and misuse. The data is accessible only through the functions, otherwise it remains hidden from users. This insulation of data from direct access by the program is called data hiding or information hiding. 5. Inheritance: It is a process by which an object inherits the properties of another object belonging to another class. Ex: ‘mango’ is part of the class fruit which again is part of the larger class food. The original class is known as base class and the new class is referred to as derived class or sub class.
  • 9.
    6. Reusability: Oncea class is created and tested and read to use, it can be distributed to other programmers for using in their programs, this is known as reusability. Inheritance supports the idea of reusability, where the programmers can add new features without modifying the existing class. 7. Polymorphism: The ability to take more than one form is called polymorphism. Ex: All brands of air conditioners do the same work, cooling the temperature. Ex: Addition operator + is used to add two values and even it is used to concatenate two strings. This process of an operator acquiring different behavior in different instances is known as operator overloading.
  • 10.
    8. Dynamic binding: Bindingrefers to the process of resolving the function to be associated with the function call. There are two types… 1. Static binding: Binding takes place during compilation. It is also known as early binding. 2. Dynamic binding: It is also called as late binding, coz the code associated with a given function call is not known until run-time. 9. Message communication: A message is nothing but execution of a procedure. Message communication involves specifying the name of the object, name of the function and the information to be sent. For Ex: consider a class called stack. stack1.push(1); here stack1 is object, push is a function and 1 is information.
  • 11.
    Applications of OOP 1.Real-time systems. 2. Object oriented database. 3. Artificial intelligence and expert systems. 4. Simulation and modeling. 5. Neural networks. 6. Office automation systems.
  • 12.
    Difference between POPand OOP Procedure Oriented Object oriented Focus is on functions Focus is on data Data is not secured Data is secure. Uses top down programming design Uses bottom up programming design Does not model real world problem Models real world problems Programs are divided into functions Programs are divided into objects