Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
6 views6 pages

Final Lesson Week 14 Report C++

Data Abstraction in C++ is a fundamental concept of Object-Oriented Programming that involves hiding internal implementation details while exposing only necessary information through interfaces. It is achieved using classes and access specifiers (public, private, protected), which help reduce complexity, improve security, and enhance code reusability. The document also provides a real-life analogy of a car and discusses the importance and advantages of using data abstraction in programming.

Uploaded by

JM Hiponia Jaem
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)
6 views6 pages

Final Lesson Week 14 Report C++

Data Abstraction in C++ is a fundamental concept of Object-Oriented Programming that involves hiding internal implementation details while exposing only necessary information through interfaces. It is achieved using classes and access specifiers (public, private, protected), which help reduce complexity, improve security, and enhance code reusability. The document also provides a real-life analogy of a car and discusses the importance and advantages of using data abstraction in programming.

Uploaded by

JM Hiponia Jaem
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/ 6

Lesson: C++ - Data Abstraction

JM’S PART

I. What is Data Abstraction?

Data Abstraction in C++ is a key concept of Object-Oriented Programming (OOP). It


refers to hiding the internal implementation details and showing only the necessary
information to the user.

 It's like using a TV remote – you know what buttons to press (interface), but you
don’t know how it works inside (implementation).

In C++, abstraction is achieved mainly using:

 Classes

 Access Specifiers (public, private, protected)

II. Real-Life Analogy

Think of a Car:

 When you drive a car, you use the steering wheel, accelerator, and brake.

 You don’t need to know how the engine, transmission, or braking system work.

 The car manufacturer hides the complexity and provides a simple interface to
drive the car.

This is abstraction: hiding complexity and exposing only the essentials.

III. Why is Data Abstraction Important?


 Reduces complexity for the user

 Improves code reusability

 Enhances security (data is not directly accessible)

 Makes code more maintainable and scalable

 Helps in managing large codebases


[HAZEL’S PART]

IV. Access Specifiers and Abstraction

In C++, access specifiers control how members (variables and functions) of a class can
be accessed:

Specifier Description

Members are hidden from outside the class. Used for internal
private
implementation.

public Members are accessible from outside. Used as interface to the class.

protected Like private but accessible in derived classes.

(TAKE NOTE: ) The idea is to hide internal data (private) and expose only what is
necessary (public).

[LANIBA’S PART]

V. Syntax of Data Abstraction using Classes


VI. Explanation of the Example

In the above program:

 accountHolder and balance are private → they cannot be accessed directly.

 Functions like deposit(), withdraw(), and displayBalance() are public → they act
as the interface for the user.

 The internal implementation of how the balance is managed is abstracted away


from the user.

[EDUARD’S PART]
VII. Advantages of Using Abstraction in This Code

 Encapsulation of data – no direct access to balance

 User-friendly interface – just use deposit/withdraw functions

 Flexible for future changes – logic can change without affecting interface

 Security – prevents misuse of critical data

[JONVERT’S PART]

VIII. Comparison: Without Abstraction

If we allowed direct access like this:

account.balance = -1000;

 It would break the logic and allow invalid data.


 Using abstraction prevents this.

[LUMNA’S PART]

IX. Summary

Concept Explanation

Data Hiding the internal implementation and showing only necessary


Abstraction features
Concept Explanation

Achieved by Using classes and access specifiers (private, public)

Purpose Reduce complexity, improve security, and promote reusability

C++ Tools Classes, Objects, Access Specifiers

X. Challenge for Practice

Create a Student class with:

• Private data: name, grade, studentID


• Public functions: setDetails(), getDetails(), updateGrade()

ANSWER:
EXPLANATION:

 name, studentID, and grade are private: hidden


 setDetails(), getDetails(), and updateGrade() are public: user interface
 Invalid grades are prevented from being assigned: secure & validated
data

You might also like