C++ Tutorial Home Page

C++ OOPs Concepts

Introduction
Class
Objects
Abstraction
Encapsulation
Polymorphism
Inheritance
Dynamic Binding
Message Passing

C++ OOPs Concepts 5

Abstraction

Abstraction refers to the act of representing essential features without including the background details or explanations.

Example:1:

Using a switchboard, we need to know only its essential features that is what all switches are to be pressed, and the background details like wiring and circuitry are hidden from the user.

 

Example:2:

To understand the concept of abstraction let’s take the example of car, we know the essential features of the car are gear, steering wheel, breaks, clutches, etc. But while driving a car we don’t bother about knowing details / internal of working of gear, steering wheel, breaks, clutches, engine, we just drive the car, this is an abstraction.

 

Example:3

Abstraction in Header files: One more type of abstraction in C++ can be header files. For example, consider the pow() method present in math.h header file. Whenever we need to calculate the power of a number, we simply call the function pow() present in the math.h header file and pass the numbers as arguments without knowing the underlying algorithm according to which the function is actually calculating the power of numbers.

Abstraction supports “data hiding” so that only relevant information is exposed to the user and the rest of the information remains hidden from the user.