What is encapsulation with examples

 Defination :- Encapsulation involved similar data and function into a single unit is called the encapsulation unit .

By encapsulating a encapsulation a data we protect that data from change it also information hidding .

* Declear the class method a binding C++.

                                     Class

                                   Data Member 

                                   Member Function.


Class Rectangle :-

{ Public : int length : int breath ; int get Area ()

{ return length * breath: } 

}

Class is the best examples of encapsulation .

There are two important properties of encapsulation .

1. Data Protection 

2. Information Hidding

Data Protection :-  Encapsulation protect the internal stack of an object repeting data member private , Access to an modification of these data member is restricted to the class public method insuring controlles and secure data manipulation of information hidding . 

Encapsulation hides the internal implementation details of class from external code only the public interface class an accessible providing abstraction name simplefying the uses of the class wild allowing the implementation to be modify without impecting external code .

Information Hidding :- By intractive only within object methods the details of an object its internal implementation remain within from the outside world . 






Post a Comment

0 Comments