Discuss about Information Hiding

Estudies4you
Q24. Discuss about Information Hiding.
Answer:

Information hiding means hiding the class member variables and member functions. The process of hiding data involves hiding a class by declaring the data members and member functions within a “private” section. Mostly, member variables are declared as private and member functions as public. The data members that are declared as private cannot be accessed outside the class. Thereby, security is provided to the data. These private members are accessed by using public member functions. Generally, private and protected are the keywords that are used to provide security. The data that is encapsulated can also be called as ADT (Abstract Data Types). Information hiding is a process to build objects.

Program
//Program to demonstrate information hiding is as given below,
#include<iostream.h>
#include<conio.h>
class Student
{
private:
int val1,val2;
int result;
public:
void calculate()
{
vall=20; .
val2=30;
result = vall+val2;
}
void display()
{
cout<<"The Entered values are:";
cout<<vall<<" "<<val2;
cout<<"\nSum is:"<<result;
}
};
int main()
{
Student stu;
clrscr();
stu.calculate();
stu.display();
getch();
return 0;
}
Output
Discuss about Information Hiding in c++,use of information hiding in c++,define class in c++,syntax for class,class syntax,data abstraction in c++,data hiding in c++,what is object,difference between class and object,how to declare a object to class,what is scope of class in c++,types of scopes in c++,estudies4you,pointers in c++,static members of a class in c++,Static Member Function in c++, constructor and destructors in c++,difference between constructor and destructor,define constructor,define destructor,static member functions,data abstraction definition,short notes on data abstraction,types of abstraction in c++,what is ADT in c++,abstract data type in c++,information hiding in c++,
To Top