What is encapsulation? Why is it useful
belongs to book: C++ Primer|Stanley B.Lippman, Josee Lajoie, Barbara E.Moo|5th Edition| Chapter number:7| Question number:18
All Answers
total answers (1)
belongs to book: C++ Primer|Stanley B.Lippman, Josee Lajoie, Barbara E.Moo|5th Edition| Chapter number:7| Question number:18
total answers (1)
Encapsulation enforces the separation between interface and implementation in a class via access specifiers. Encapsulation provides some advantages:
- A class that is encapsulated hides its implementation to the user of the class, thus the user need not know how the class works, they can regard the class as a type (like a built-in type) instead.
- User code cannot inadvertently corrupt the state of an encapsulated object.
- The implementation of an encapsulated class can change over time without requiring changes in user code.
need an explanation for this answer? contact us directly to get an explanation for this answer