Building Classes in C++  «Prev  Next»
Lesson 12
Object Oriented Programming Conclusion
In this module, the basic concept of encapsulation in C++'s implementation of object-oriented programming.
You learned:
  1. Why encapsulation is central to object-oriented programming
  2. What classes and objects are
  3. How to write member functions as part of an abstract data type
  4. How to limit access to an ADT's member data and functions
  5. How a class differs from a struct

OOP Encapsulation Quiz
Encapsulation is a technique that extends the concept of abstraction from a strictly data phenomena to both data and functions.
If you think of the data abstraction used in C, the structure, then it is easy to grasp the idea that a class encompasses what a structure did and then extends the concept to include the binding of functions into the single entity.
Click the Quiz link below to take a multiple-choice quiz covering the topics presented in this module.
OOP Encapsulation Quiz


All C++ programs are composed of the following two fundamental elements:
  1. Program statements (code): This is the part of a program that performs actions and they are called functions.
  2. Program data: The data is the information of the program which affected by the program functions.
Encapsulation is an Object Oriented Programming concept that binds together the data and functions that manipulate the data, and that keeps both safe from outside interference and misuse. Data encapsulation led to the important OOP concept of data hiding.
Data encapsulation is a mechanism of bundling the data, and the functions that use them and data abstraction is a mechanism of exposing only the interfaces and hiding the implementation details from the user.
C++ supports the properties of encapsulation and data hiding through the creation of user-defined types, called classes. We already have studied that a class can contain private, protected and public members. By default, all items defined in a class are private. For example: