Programming Languages‎ > ‎C++‎ > ‎

01. Encapsulation

Encapsulation
  • The single most important reason to use Encapsulation is to reduce a program's complexity.

Encapsulation Objects
  • When you create an object in an object-oriented language, you can hide the complexity of the internal workings of the object. 
  • As a developer, there are two main reasons why you would choose to hide complexity.
      1. The first reason is to provide a simplified and understandable way to use your object without the need to understand the complexity inside.
      2. The second reason for hiding complexity is to manage change.

    Encapsulation: C vs C++
    • By default, C struct members are public.
    • With a C++class, the default is private. 
    • Classes are essentially private structures. 
    • C++ uses public interfaces (member functions) to access the private data (member data). 
    • Classes and structs behave identically.

    Comments