Encapsulation


Encapsulation encloses data and functionality into a single unit (called a class):

encapsulation.png
In C++, data and functionality are separated into two separate protections: public and private.

encapsulationPrivatePublic.png

Public vs Private

The protection level determines the access that "client code" has to the member data or functionality:


Encapsulation # 2

In C++, the interface (.h file) to the class is defined separately from the implementation (.cpp file).