0% found this document useful (0 votes)
2K views5 pages

Chap: 1: Procedural Oriented Programming (POP)

C++ is an object-oriented programming language that was developed as an extension of C. It supports concepts like classes, objects, inheritance and polymorphism. Object-oriented programming focuses on data rather than procedures and divides programs into reusable objects. This document compares procedural programming and object-oriented programming, and describes key concepts in OOP like classes, objects, encapsulation, inheritance and polymorphism. It also provides examples of these concepts in C++.

Uploaded by

Chitra Bhuskute
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2K views5 pages

Chap: 1: Procedural Oriented Programming (POP)

C++ is an object-oriented programming language that was developed as an extension of C. It supports concepts like classes, objects, inheritance and polymorphism. Object-oriented programming focuses on data rather than procedures and divides programs into reusable objects. This document compares procedural programming and object-oriented programming, and describes key concepts in OOP like classes, objects, encapsulation, inheritance and polymorphism. It also provides examples of these concepts in C++.

Uploaded by

Chitra Bhuskute
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

C++ (Chap: 1)

Procedural Oriented Programming (POP):


Procedural Oriented Programming consists of finding, writing and organising into groups
known as "FUNTIONS", while importance is given to writing Functions and very little
importance is given to data being used by various functions.

The data items may be global and hence accessible by many functions

Global data are more vulnerable to change by a function in a large program. It is very
difficult to identify what data is used by which function since many function access same
data, the way the data is stored becomes critical. The arrangement of data can't be changed
without modifying all functions that access it. If new data items are added you need to
modify all function that the access so that it can access new items.

Another Drawback with the Procedural approach is that it does not model real world
problem very well. In Procedural Oriented approach there are more problems when
programs are larger and complex.

Object Oriented Programming (OOP):


Definition:
"Object Oriented Programming is an approach that provides a way of modulizing programs
by creating partition memory area for both data and function that can be used as templates
for creating copies of such modules on demand."

C++ is an Object Oriented Programming Language. Initially it was named "C with Classes".
C++ was developed by "BJARNE STROUPSTRAUP".

FEATURES / CHARACTERISTICS:
POP:

 Emphasis is on doing things.


 Large programs are divided into smaller programs known as functions.
 Most of the functions share global data and data moves openly around the system
from one function to another.
 Employees top down approach in program design.
 Object oriented programming paradigms.
OOP:

 Emphasis is on data rather than on procedure.


 Programs are divided into objects.
 Data is hidden and cannot be accessed by external functions.
 Object can communicate to each other through functions.
 New data and points can be easily added whenever necessary.
 Follows Bottom-Up Approach in program design.

Basic Functions of OOP:


OBJECT:

 Objects are basic runtime entities in an Object oriented system. Object may
represent a person, a place, a bank a/c or any item that a program has to handle.
Program object should be chose such that they match closely with real world
objects. Object takes up space in the memory when the program is executed. The
objects interact by sending messages to one another.
 For Example:

If Customer and account are two Objects in a program, then a customer object may
send a message to account Object requesting for the bank balance.

 Each object contains data and code to manipulate the data. Objects can interact
without having to know the details of each other's data or code.

CLASS:

 The entire set of data and code of an object can be made into a user-defined data-
type of a class. Objects are the variables of type class. Once a class has been defined
we can create any number of objects belonging to that class. Each object is
associated with data of type class with which they are created. A class is a collection
of object of similar type.

 Example: Mango, apple, oranges etc. from class fruit. Classes are user-defined data-
types and behave like built-in data-types of programming language.

DATA ABSTRACTION AND ENCAPSULATION:

 The wrapping up of data of a function into a single unit called Class is called
"Encapsulation".
 The data is not accessible to outside world and only those functions which are
wrapped in class can access it. These functions provide an interface between Object
Data and Programs.
 The insulation of data from direct access by the program is called as "Data Hiding".
 Abstraction refers to the act of representing essential features without including the
background details or explanation.
 Classes use the concept of abstraction. They are defined as a list of abstract
attributes such as size, weight, cost and function to operate on these attributes. They
encapsulate all essential properties of the object that are to be created.
 Since classes use the concept of abstraction they are known as abstract data-types,
attributes are called members and functions that operate in these data are called
member functions.

INHERITANCE:

 Inheritance is a process by which object of one class acquires the properties of


objects of another class. In OOP the concept of inheritance provides the idea of
reusability, this means that we can add additional features to an existing class
without modifying it. This is done by deriving a new class from an existing one.
 A new class will have the combined features of both the classes.

POLYMORPHISM:

 Polymorphism is a Greek term which means ability to take more than one forms.
 An operation may exhibit different behaviour in different instances. The behaviour
depends upon the types of data used in the operation.
 For Example:

The operation of addition will generate a sum. But if then open hands are
strings then the operation will result in third string by concatenation.

 The process of making an operator to exhibit different behaviour in different


instances is known as operator overloading.
 Using a single function name to perform different types of task is known as function
overload.
 Polymorphism plays an important role in allowing objects having different internal
structure to share the same external interface.

DYNAMIC BINDING:

Binding refers to linking of a procedure call to the code to be executed in response to the
call. Dynamic Binding is also known as "Late Binding" means that the code associated with
given procedure call is not known until the time of the call at runtime. It is associated with
the polymorphism and inheritance.
MESSAGE PASSING:

 An object oriented program consists of a set of object that communicates with each
other.
 Programming in an Object Oriented Language consists of following steps:
i. Creating classes that defines object and behaviour.

ii. Creating objects from class definition.

iii. Establishing communication among objects.

A message for an object is a request for execution of a procedure and therefore will invoke a
function in the receiving object that generates the desired result. Message Passing involves
specifying the name of the function (message) and the information to be sent.

Employee Salary (Name)

Object Message Information

Applications Of C++:
I. Used for any real life application system editor, complier, database, communication
system.
II. Object Oriented Libraries can be built by C++.
III. C++ programs can be easily implemented maintained and expanded.

Operators in C++:
#include<iostream.h>
Void main()
{
Cout << "C with classes"; (<< - Insertion or put to operator)
Cin >> a; (>> - Extraction or get from operator)
}

INSERTION OPERATOR: (<<)


The insertion operator is also called as put on operator. It inserts (or sends) the contents of
the variable on the variable on its right to the object to the left.
E.G. :
Cout << a;
The value of the variable 'a' is printed on the screen.
Cout << "programs";
The word program is printed on the screen. The identifier cout is a predefined object that
represents. The standard output stream represents the screen.

EXTRACTION OPERATORS: (>>)


The extraction operator is also called as got from operator. It extracts or takes the value
from the keyword and assigns it to the variable on its right.
E.G. :
Cin >> a
This will extract the 'a' value from the keyboard and assign it to the variable 'a'.

You might also like