Object Oriented Programming Using C++

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 13

Object Oriented Programming

using C++
- Ms. Salima Khatib
- Lecturer (Information Technology)
Procedure Oriented Language

• Procedure oriented programming


is a set of functions.
• To perform any task, set of
function are compulsory.
• For example , a program may
involve collecting data from
user, performing some kind of
calculation on that data and
printing the data on screen when
is requested. 
Object Oriented Programming

• Object-oriented
programming (OOP) is
a programming language based on
the concept of "objects", which can
contain data, in the form
of fields (often known
as attributes or properties), and code,
in the form of procedures (often
known as methods).
• A feature of objects is that an object's
own procedures can access and often
modify the data fields of itself.
Procedure Oriented Language Object – Oriented Language
In procedural programming, program is divided into In object -oriented programming, program is divided into
small parts called functions. small parts called objects.

Procedural Oriented Language follows top down Object Oriented Programming follows Bottom up
approach approach

There is no access specifier in procedural Object oriented programming have access specifiers like
programming. private, public, protected etc.

Adding new data and function is not easy. Adding new data and function is easy.
Procedural programming does not have any proper way Object oriented programming provides data hiding so it
for hiding data, so it is less secure. is more secure.
Procedural programming is based on unreal world. Object oriented programming is based on real world.
Examples: C, FORTRAN, Pascal, Basic etc. Examples: C++, Java, Python, C# etc.

Procedure Oriented versus Object Oriented


Programming Language
Procedure Oriented versus Object Oriented
Programming Language
Basic Groups of Object-Oriented Programming

• Class: The building block of C++ that leads to Object-Oriented


programming is a Class. It is a user-defined data type, which holds its own
data members and member functions, which can be accessed and used by
creating an instance of that class. A class is like a blueprint for an object.
• For Example: Consider the Class of Cars. There may be many cars with
different names and brand but all of them will share some common
properties like all of them will have 4 wheels, Speed Limit, Mileage range
etc.
• Object: An Object is an identifiable entity with some characteristics and
behavior. An Object is an instance of a Class. When a class is defined, no
memory is allocated but when it is instantiated (i.e. an object is created)
memory is allocated.
• Encapsulation: In normal terms, Encapsulation is defined as wrapping up
of data and information under a single unit.
• In Object-Oriented Programming, Encapsulation is defined as binding
together the data and the functions that manipulate them.
• For example: In a company, there are different sections like the accounts
section, finance section, sales section etc.
• Abstraction: Data abstraction is one of the most essential and important
features of object-oriented programming in C++.
• Abstraction means displaying only essential information and hiding the
details. 
• A man driving a car. The man only knows that pressing the accelerators will
increase the speed of the car or applying brakes will stop the car but he
does not know about how on pressing accelerator the speed is actually
increasing, he does not know about the inner mechanism of the car or the
implementation of accelerator, brakes etc in the car.
• Polymorphism: The word polymorphism means having many forms. In
simple words, we can define polymorphism as the ability of a message to
be displayed in more than one form.
• For Example: A person at the same time can have different characteristic.
Like a man at the same time is a father, a husband, an employee. So the
same person posses, different behavior in different situations.
Object-oriented languages include: 
• Java,
• C++, C#, 
• Python, Object-
• R, Oriented
• PHP, 
• Visual Basic.NET,
Languages
• JavaScript, 
• Ruby etc.
Application Of Object-Oriented Programming
Language
Main application areas of OOP are:
• User interface design such as windows, menu.
• Real Time Systems
• Simulation and Modeling
• Object oriented databases
• AI and Expert System
• Neural Networks and parallel programming
• Decision support and office automation systems etc.
Basis of distinction C C++

Programming type It is a Procedural Oriented language. It is an Object-Oriented Programming language.

C language follows Top Down programming


Approach C++ follow bottom-up programming approach.
approach
The file extension of a c+ + program language
File extension The file extension of a C program is .c
is.cpp
In C programming language, a big program
In C++ programming language, a big program
Program division code is divided into small pieces which is
code is divided into Objects and Classes.
called functions.
C versus Structure in C not provide the feature of
Structure in C++ provides the feature of
Structure declaring a function as a member function of
C++ function declaration.
the structure.
Inline function It does not allow inline function. It supports inline function.
In C scanf and printf are used for the standard In C++ cin» and cout« are given for standard
Standard I/O operations
input and output input and output operations.
Data is secure, so it can't be accessed by
Data Security In C language the data is not secured. external functions. (Using Encapsulation
concept of OOPs)
C is an older programming language that is
described as Hands-on. In this language, you
C++ is an extension language of C. It allows for
Ease of Coding must tell the program to do everything.
the highly controlled object-oriented code.
Moreover, this language will let you do almost
anything.

You might also like