0% found this document useful (0 votes)
26 views12 pages

OOP2

Uploaded by

PRASANT KUMAR
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)
26 views12 pages

OOP2

Uploaded by

PRASANT KUMAR
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/ 12

Object­oriented programmings

(OOPs)
● Object­oriented programming
aims to implement real­world
entities like inheritance,
hiding, polymorphism, etc in
programming
● The main aim of OOP is to
bind together the data and
the functions that operate on
them so that no other part of
the code can access this data
except that function
Procedure OR Object Oriented?

Procedure Oriented Programming Object Oriented Programming


Program is divided into small parts called Program is divided into parts called objects.
functions.

Importance is not given to data but to functions Importance is given to the data rather than
as well as sequence of actions to be done. procedures or functions because it works as a
real world.

follows Top Down approach. OOP follows Bottom Up approach.

It does not have any access specifier. OOP has access specifiers named Public,
Private, Protected, etc.

Data can move freely from function to function objects can move and communicate with each
in the system. other through member functions.
Procedure OR Object Oriented?
Procedure Oriented Programming Object Oriented Programming
To add new data and function in POP is not OOP provides an easy way to add new data and
so easy. function.

Most function uses Global data for sharing In OOP, data can not move easily from
that can be accessed freely from function to function to function,it can be kept public or
function in the system. private so we can control the access of data.

It does not have any proper way for hiding OOP provides Data Hiding so provides more
data so it is less secure. security

Overloading is not possible In OOP, overloading is possible in the form of


Function Overloading and Operator
Overloading

Example of Procedure Oriented Example of Object Oriented Programming are :


Programming are : C, VB, FORTRAN, C++, JAVA, VB.NET, C#.NET.
Pascal
Principles( or features) of object oriented
programming
● Encapsulation
● Data abstraction
● Polymorphism
● Inheritance
● Dynamic binding
● Message passing
Class and Objects
Encapsulation
Wrapping of data and functions together as a
single unit is known as encapsulation. By default
data is not accessible to outside world and they
are only accessible through the functions which
are wrapped in a class. prevention of data direct
access by the program is called data hiding or
information hiding
Data abstraction
● Abstraction refers to the act of representing essential
features without including the back ground details or
explanation. Classes use the concept of abstraction and
are defined as a list of attributes such as size, weight, cost
and functions to operate on these attributes. They
encapsulate all essential properties of the object that are
to be created. The attributes are called as data members
as they hold data and the functions which operate on
these data are called as member functions.
● Class use the concept of data abstraction so they are
called abstract data type (ADT)
Polymorphism
● Polymorphism comes from the Greek words “poly” and
“morphism”. “poly” means many and “morphism” means form
i.e.. many forms. Polymorphism means the ability to take
more than one form. For example, an operation have different
behavior in different instances. The behavior depends upon
the type of the data used in the operation.
Inheritance
● Inheritance is the process by which one object can acquire the properties of another
● Inheritance is the most promising concept of OOP, which helps realize the goal of
constructing software from reusable parts, rather than hand coding every system from
scratch. Inheritance not only supports reuse across systems, but also directly facilitates
extensibility within a system. Inheritance coupled with polymorphism and dynamic binding
minimizes the amount of existing code to be modified while enhancing a system.
● When the class child, inherits the class parent, the class child is referred to as derived
class (sub class) and the class parent as a base class (super class). In this case, the class
child has two parts: a derived part and an incremental part. The derived part is inherited from
the class parent. The incremental part is the new code written specifically for the class child.
Dynamic Binding
● Binding refers to linking of procedure
call to the code to be executed in
response to the call. Dynamic binding(or
late binding) means the code associated
with a given procedure call in not known
until the time of call at run time.
Message passing
● An object oriented program consists of set of
object that communicate with each other.
Objects communicates with each other by
sending and receiving information .

● A message for an object is a request for


execution of a procedure and there fore
invoke the function that is called for an
object and generates result
First CPP program

#include <iostream>

using namespace std;

int main()
{
cout << "Hello World" << endl;
return 0;
}

You might also like