
- OOAD Tutorial
- OOAD - Home
- OOAD - Object Oriented Paradigm
- OOAD - Object Oriented Model
- OOAD - Object Oriented System
- OOAD - Object Oriented Principles
- OOAD - Object Oriented Analysis
- OOAD - Dynamic Modelling
- OOAD - Functional Modelling
- OOAD - UML Analysis Model
- OOAD - UML Basic Notations
- OOAD - UML Structural Diagrams
- OOAD - UML Behavioural Diagrams
- OOAD - Object Oriented Design
- OOAD - Implementation Strategies
- OOAD - Testing & Quality Assurance
- OOAD Useful Resources
- OOAD - Quick Guide
- OOAD - Useful Resources
OOAD Princhiples Q/A #8
Question:What do you mean by data hiding? How to implement data hiding in C++? Give an example.
Answer:
data hiding
Data hiding or encapsulation, is the mechanism in which implementation details of a class are kept hidden from the user. The user can only perform a certain restricted set of operations on the hidden members of the class by executing special functions called methods.
How data hiding is implemented in C++
The data hiding concept is supported in C++ using the pubic, protected and private keywords which are placed in the declaration of the class. Anything in the class placed after the public keyword is accessible to all the users of the class. Elements placed after the protected keyword are accessible only to the class or classes derived from that class. Elements placed after the private keyword are accessible only to the class members.
Advantage of data hiding
Maintenance of application is easier.
Data hiding enhances the data security and data will not get corrupted as it is not easily accessible.
It reduce the human errors. The data and function are bundled inside the class to take total control of maintainance and thus human errors are reduced.
It improves the understandability of the application.