Several features of
C++ encourage encapsulation. There is, of course, the foundation of
C++ OO, the
class, with
access specifiers that limit the rights other functions have to access the contents of the class. Generally speaking, good programming practice is that all
data members should be protected or private. Even
derived classes should avoid accessing the
base class' contents directly. The Windows APIs are a good example of this; most
windows programmers have no knowledge of the
OS