Amrit Kaur Functions in C++
1
Chapter 6: Introduction to Object Oriented Programming
6.1 Limitation of Procedural Programming
Procedural programming is a programming paradigm, based upon the concept of the
procedure and procedure calls. Procedures, also known as routines, subroutines, or
functions simply contain a series of
computational steps to be carried out. The
limitations are as follows
 Functions are the building block not
data. Therefore it becomes sometimes
very difficult to point or identify which
function modify or corrupt the data.
 Lack of abstraction: Structure can be used
to model the data but functions are
global.
 Uninitialized Variables
 Resource De allocation Problem: Resources may be Memory leaks, open files,
Open database or network connection. It is the program responsibility to
deallocate.
 No reusability: Portions of code or functions are so interdependent that the code in
one application cannot be reused in another.
 No Resilience to Change: Because of interdependence between functions, software
is not resilient to change.
6.2 Object Oriented Programming
Object Oriented Programming views a system as a collection of real world objects
that are categorized as classes.
In object oriented programming, focus is on
the organization of software into collection
of components called objects that group
together related items of data, known as
state and operations to be performed on
data known as behaviour.
What are Object?
An object is a tangible entity that exhibits some well defined behavior. According to
Grady Booch, an object has following characteristics
• It has state. The state is indicated by set of attributes and their values
• It may display a behavior. Behavior refers to operations performed by it. It also
means ow an object act and react in terms of state change and message passing.
Amrit Kaur Functions in C++
2
• Object has unique identity.
For Example, a student has rollno and enrolment no (identity). Student have some
attributes (states), like, name, class, semester, branch, mobile no, email id etc. They
perform certain functions like reading, studying, playing, sleeping, eating etc.
What are Classes?
The objects we see in the world can be classified on the basis of common attributes
and behaviour. Lets us take a simple example. The mango, apple and grapes are all
fruits. All of them share some common characteristics. All three have characteristics
that are common to family (class) of Birds. Thus, A class is set of similar object that
exhibit some well defined behaviour.
6.3 Characteristics of Object Oriented Programming
The important characteristics of an object oriented language is
1. Abstraction
2. Encapsulation
3. Inheritance
4. Polymorphism
6.3.1 Abstraction
According to Grady Booch, abstraction represents essential characteristics of an
object that differentiates it from other objects and provides crisply defined
conceptual boundaries with respect to viewer’s perspective.
6.3.2 Encapsulation
According to Grady Booch, encapsulation is a process of hiding all the details of
an object that don’t contribute to its essential characteristics. That is, hiding
implementation detail of an object.
Abstraction and encapsulation complement each other. Encapsulation
implements abstraction by providing a means to hide non essential details.
In OOP language, abstraction and encapsulation is implemented using access
specifiers (public, private and protected)
Amrit Kaur Functions in C++
3
6.3.3 Inheritance
Inheritance is a process of creating a new class called a derived class, from an
existing class called the base class.
The concept of inheritance provides an important feature of OOP – reusability.
The programmer can use (inherit) an existing class (base) and with modifying it,
can add additional attributes and behaviour to a new class(derived).
6.3.4 Polymorphism
The word polymorphism is derived from two latin words, ‘poly’ means many and
‘morphos’ means forms. Polymorphism is defined as ability of an object to
behave differently under different circumstances.

Chapter 6 OOPS Concept

  • 1.
    Amrit Kaur Functionsin C++ 1 Chapter 6: Introduction to Object Oriented Programming 6.1 Limitation of Procedural Programming Procedural programming is a programming paradigm, based upon the concept of the procedure and procedure calls. Procedures, also known as routines, subroutines, or functions simply contain a series of computational steps to be carried out. The limitations are as follows  Functions are the building block not data. Therefore it becomes sometimes very difficult to point or identify which function modify or corrupt the data.  Lack of abstraction: Structure can be used to model the data but functions are global.  Uninitialized Variables  Resource De allocation Problem: Resources may be Memory leaks, open files, Open database or network connection. It is the program responsibility to deallocate.  No reusability: Portions of code or functions are so interdependent that the code in one application cannot be reused in another.  No Resilience to Change: Because of interdependence between functions, software is not resilient to change. 6.2 Object Oriented Programming Object Oriented Programming views a system as a collection of real world objects that are categorized as classes. In object oriented programming, focus is on the organization of software into collection of components called objects that group together related items of data, known as state and operations to be performed on data known as behaviour. What are Object? An object is a tangible entity that exhibits some well defined behavior. According to Grady Booch, an object has following characteristics • It has state. The state is indicated by set of attributes and their values • It may display a behavior. Behavior refers to operations performed by it. It also means ow an object act and react in terms of state change and message passing.
  • 2.
    Amrit Kaur Functionsin C++ 2 • Object has unique identity. For Example, a student has rollno and enrolment no (identity). Student have some attributes (states), like, name, class, semester, branch, mobile no, email id etc. They perform certain functions like reading, studying, playing, sleeping, eating etc. What are Classes? The objects we see in the world can be classified on the basis of common attributes and behaviour. Lets us take a simple example. The mango, apple and grapes are all fruits. All of them share some common characteristics. All three have characteristics that are common to family (class) of Birds. Thus, A class is set of similar object that exhibit some well defined behaviour. 6.3 Characteristics of Object Oriented Programming The important characteristics of an object oriented language is 1. Abstraction 2. Encapsulation 3. Inheritance 4. Polymorphism 6.3.1 Abstraction According to Grady Booch, abstraction represents essential characteristics of an object that differentiates it from other objects and provides crisply defined conceptual boundaries with respect to viewer’s perspective. 6.3.2 Encapsulation According to Grady Booch, encapsulation is a process of hiding all the details of an object that don’t contribute to its essential characteristics. That is, hiding implementation detail of an object. Abstraction and encapsulation complement each other. Encapsulation implements abstraction by providing a means to hide non essential details. In OOP language, abstraction and encapsulation is implemented using access specifiers (public, private and protected)
  • 3.
    Amrit Kaur Functionsin C++ 3 6.3.3 Inheritance Inheritance is a process of creating a new class called a derived class, from an existing class called the base class. The concept of inheritance provides an important feature of OOP – reusability. The programmer can use (inherit) an existing class (base) and with modifying it, can add additional attributes and behaviour to a new class(derived). 6.3.4 Polymorphism The word polymorphism is derived from two latin words, ‘poly’ means many and ‘morphos’ means forms. Polymorphism is defined as ability of an object to behave differently under different circumstances.