4.1. What Is Encapsulation?

Object-oriented languages like C++ enable you to create your own data types. This is important for several reasons.

  • New data types make programs easier to visualize and implement from designs.

  • User-defined data types are reusable.

  • You may modify and enhance new data types as programs evolve and specifications change.

  • New data types let you create objects with simple declarations.

An object is an instantiation of a data type. Here are some examples.

Window w;                      // Window object 
Database ood;                  // Database object
Device d;                      // Device object

Once we create new data types and instantiate objects, what can programs do with them? New data types come with a set of legal operations, or methods. Programs manipulate objects through ...

Get Navigating C++ and Object-Oriented Design now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.