Encapsulation is the wrapping up of data and variables (that work on the data) into a single unit (called class).
The only way to access the data is provided by the functions (that are combined along with the data). These functions are called member functions in C++. If you want to read a data item in an object (an instance of the class), you call a member function in the object. It will read the item and return the value to you. The data is hidden and so is safe from accidental alteration.
Encapsulation is a way of implementing data abstraction. Encapsulation hides the details of the implementation of an object.
You have viewed 1 page out of 62. Your C++ learning is 0.00% complete. Login to check your learning progress.