What is Data Hiding In C++
It is a process of combining data and functions into a single unit. This is the central idea of OOP. Usually, the data within a class is
private & the functions are
public The data is hidden (in OOP data is given more importance than function as data is the reason for program's existence) so that it will be safe from accidental manipulation.
Example: We go a bank & access the staff rather than the computers and files over there. The bank staff knows how to access those Computers and files.
It means that
data is concealed (masked) within a class so that it cannot be accessed by functions outside the class even by mistake. The
mechanism used to
hide data is to put it in a class & make it private
Example of Data hiding in C++
The value is 666
Explanation of the program
We do not manipulate the
data directly. We can do so only by using functions and objects.
© 2016-2019, Codeverb.com - All Rights Reserved