MENU
Question -

Explain data hiding with an example.



Answer -

Data Hiding
Data Hiding is the mechanism where the details of the class are hidden from the user.
The user can perform only a restricted set of operations in the hidden member of the class For example,
In order to make the design and maintenance of a car reasonable the complexity of equipment is divided into modules with particular interfaces hiding design decisions.
General Form:

class classname
 {
 private:
datatype data;
    public:
       Member functions,-'
 };
 main()
 {
 classname objectnamel, objectname2
.........;
 {
 Example :
class Square
{
 private
 int Num;
 public:
 void Get() {
 cout<<"Enter Number:";
 cin>>Num;
 }
 void Display!) { cout<<"Square Is:"<
 }
 };
 void main()
 {
 Square Obj;
 Obj.Get();
 Obj.Display ();    [1]
 getch()
 }

Comment(S)

Show all Coment

Leave a Comment

Free - Previous Years Question Papers
×