+ 5

Did not understand the encapsulation? Any one tell me in detail.

C++

30th Dec 2017, 3:02 PM
Ritesh Kumbhare
Ritesh Kumbhare - avatar
2 Réponses
+ 7
It is basically hiding of data
30th Dec 2017, 4:49 PM
Victor
Victor - avatar
+ 3
Let's use an example. You start out storing addresses as part of your class. You hide the data by making it private and provide a method to return it. Later, you decide you want to interface with Google Maps. With encapsulation, you can change the data to whatever is needed to implement the Google Maps implementation and only the class needs updating. The rest of the program is unaffected.
30th Dec 2017, 5:58 PM
John Wells
John Wells - avatar