0% found this document useful (0 votes)
38 views13 pages

OOP Fundamentals in C++ Explained

The document outlines the fundamental concepts of Object-Oriented Programming (OOP) using C++, comparing it with procedural programming. Key OOP concepts include classes, objects, inheritance, abstraction, encapsulation, and polymorphism, each with definitions and real-life examples. The benefits and applications of OOP are also discussed, highlighting its advantages in managing software complexity and enhancing security.

Uploaded by

appatel8325
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)
38 views13 pages

OOP Fundamentals in C++ Explained

The document outlines the fundamental concepts of Object-Oriented Programming (OOP) using C++, comparing it with procedural programming. Key OOP concepts include classes, objects, inheritance, abstraction, encapsulation, and polymorphism, each with definitions and real-life examples. The benefits and applications of OOP are also discussed, highlighting its advantages in managing software complexity and enhancing security.

Uploaded by

appatel8325
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/ 13

Chapter 1

Fundamental Concepts of OOP with C++


Procedural Vs. OOP Approach
Procedural Oriented Programming Object Oriented Programming

In procedural programming, program is divided into small In object oriented programming, program is divided into small
parts called functions. parts called objects.

Procedural programming follows top down approach. Object oriented programming follows bottom up approach.

Object oriented programming have access specifiers like


There is no access specifier in procedural 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 for Object oriented programming provides data hiding so it
hiding data so it is less secure. is more secure.
In procedural programming, overloading Overloading is possible in object
is not possible. oriented programming.

In procedural programming, function is In object oriented programming, data is


more important than data. more important than function.

Procedural programming is based Object oriented programming is based


on unreal world. on real world.

Examples: C, FORTRAN, Pascal, Basic


Examples: C++, Java, Python, C# etc.
etc.
Basic concept of OOPC

• Class
• Objects
• Inheritance
• Abstraction
• Encapsulation
• Polymorphism
Class
Class is collection of objects.
Example:
Mango, apple, orange are the members (Objects) of class fruit.
Classes are user defined data type and built-in type of programing language
Fruit mango
will create an object mango belonging to the class fruit.
Objects
An Object is an instance of a Class.
When a class is defined, no memory is allocated but when an object is created memory is
allocated.
Object are basic run time entity of an object oriented system.
Declaring Objects:
When a class is defined, only the specification for the object is defined; no memory or storage
is allocated. To use the data and access functions defined in the class, you need to create
objects.
Syntax:
Class_name Object_name;
Inheritance
The capability of a class to derive properties and characteristics from another class is called
Inheritance. Inheritance is one of the most important feature of Object Oriented
Programming.
Sub Class: The class that inherits properties from another class is called Sub class or
Derived Class.
Super Class: The class whose properties are inherited by sub class is called Base Class or
Super class.
Abstraction
Abstraction means displaying only essential information and hiding the details.
Data abstraction refers to providing only essential information about the data to the outside
world, hiding the background details or implementation.
Real life example of a man driving a car.
The man only knows that pressing the accelerators will increase the speed of 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. This is what abstraction is.
Encapsulation
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 manipulates them.
Real life example of encapsulation,
• In a company there are different sections like the accounts section, finance section, sales
section etc. The finance section handles all the financial transactions and keep records of all
the data related to finance. Similarly the sales section handles all the sales related activities
and keep records of all the sales.
• Now there may arise a situation when for some reason an official from finance section
needs all the data about sales in a particular month. In this case, he is not allowed to
directly access the data of sales section. He will first have to contact some other officer in
the sales section and then request him to give the particular data. This is what encapsulation
is.
Polymorphism
Polymorphism means "many forms”
we can define polymorphism as the ability of a message to be displayed in more than one
form.
A real-life example of polymorphism,
A person at the same time can have different characteristics. Like a man at the same time is a
father, a husband, an employee. So the same person posses different behaviour in different
situations. This is called polymorphism.
Polymorphism is mainly divided into two types:
• Compile time Polymorphism
• Runtime Polymorphism
Compile time polymorphism: This type of polymorphism is achieved by function
overloading or operator overloading.
Runtime polymorphism: This type of polymorphism is achieved by Function Overriding.
Benefits of OOP
Through inheritance we can eliminate the code and extend the use of existing class.
Reusability
Easy to understand
The principle of data hiding helps the programmer to build the secure program.
Software Complexity can be easily managed.
Application of OOP
Real-Time System design: Real-time system inherits complexities and makes it difficult to
build them. OOP techniques make it easier to handle those complexities.
Hypertext and Hypermedia: Hypertext is similar to regular text as it can be stored,
searched, and edited easily. Hypermedia on the other hand is a superset of hypertext. OOP
also helps in laying the framework for hypertext and hypermedia.
AI Expert System: These are computer application that is developed to solve complex
problems which are far beyond the human brain. OOP helps to develop such an AI expert
System
Office automation System: These include formal as well as informal electronic systems
that primarily concerned with information sharing and communication to and from people
inside and outside the organization. OOP also help in making office automation principle.
Object-oriented database: The databases try to maintain a direct correspondence between
the real world and database object in order to let the object retain it identity and integrity.
Client-server system: Object-oriented client-server system provides the IT infrastructure
creating object-oriented server internet(OCSI) applications.

You might also like