data abstraction in c++

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

2. Classes use the concept of abstraction, so they are known as abstract data types
(ADT).
3. Data abstraction is a programming (and design) technique that relies on the
separation of interface and implementation.


4. Let's take one real life example of a TV, which you can
 Turn on and off,
 Change the channel,
 Adjust the volume, and
 Add external components such as speakers, VCRs, and DVD players.


BUT you do not know its internal details, that is,

 How it receives signals through a cable,

 How it translates them, and

 Finally displays them on the screen.

5. Thus, we can say a television clearly separates its internal implementation from its

external interface and you can play with its interfaces like the power button, channel

changer, and volume control without having zero knowledge of its internals.


Abstraction using Classes: We can implement Abstraction in C++ using classes. Class

helps us to group data members and member functions using available access

specifiers. A Class can decide which data member will be visible to outside world and

which is not.

Abstraction using access Specifies:

Access specifiers help in implementing abstraction in C++. For example:

1. Members declared as public in a class, can be accessed from anywhere in the

program.

2. Members declared as private in a class, can be accessed only from within the

class.

Benefits of Data Abstraction:

1. Class internals are protected from user-level errors.

2. The class definition can be change without requiring change in user-level code.

3. Helps the user to avoid writing the low level code.

4. Avoids code duplication and increases reusability.

5. Helps to increase security of an application or program as only important details

are provided to the user.

Post a Comment

If you have any doubts, Please let me know
Thanks!

Previous Post Next Post